douxun2023 2016-08-26 07:35
浏览 29
已采纳

too long

I started following this github tutorial It successfully GET all entries and POST data to a form. So after that as I move forward I wanted to add search filters with my GET call. After a lot of researching and trying different approaches I get to the point that I always get

{
status: 401,
response: "Permission denied"
}

as my JSON response. Following this I implemented search but it didn't work: https://www.stevenhenty.com/gravity-forms-api/#filter_entries
By consulting some php people they told me it's permission issue your call is correct. So I went here and tried both methods WordPress Cookie Authentication and External Clients: Signature Authentication but the response is the same.

I'm using the Cookie NSString *string = [NSString stringWithFormat:@"%@%@?_gf_json_nonce=%@",BaseURLString,route,[[NSUUID UUID] UUIDString]]; The _gf_json_nonce after searching I got that it'll be the UDID of the phone so that is why I'm using that.
If I use the other signature one I use it as NSString *string = [NSString stringWithFormat:@"%@%@?api_key=%@&signature=%@&expires=%@",BaseURLString,route,api_key,signature,expires]; the result is the same.
So if I want to use any of this call with search filters I'm doing this

NSDictionary *params = @{@"key": @"2",
                             @"value": @"my@email.com",
                             @"operator": @"contains"};

    NSMutableDictionary *modify = [NSMutableDictionary new];
    [modify  setObject:params forKey:@"field_filters"];


    [manager GET:stringURL  parameters:modify progress:nil success:^(NSURLSessionTask *task, id responseObject) {

So any ideas how to get it authenticate so that the call can start working.

UPDATE
1: I have also tried this but it didn't work. I've also commented on it.

  • 写回答

1条回答 默认 最新

  • douyan4243 2016-09-01 09:26
    关注

    Make sure you have the search param set to a URL encoded JSON string like this:

    http://yourdomain/gravityformsapi/forms/3/entries/?api_key=[snip]&signature=[snip]%3D&expires=[snip]&search={%22field_filters%22:%20[{%22key%22:%20%222%22,%20%22value%22%20:%20%@gmailcom%22,%20%22operator%22%20:%20%22contains%22}]}
    

    So, a bit easier to read, the search param would look something like this:

    {
      "field_filters": [
        {
          "key": "2",
          "value": "@gmail.com",
          "operator": "contains"
        }
      ]
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算