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"
        }
      ]
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?