在AFNetworking 3 GET请求

时间:2016-10-17 07:06:25

标签: ios objective-c afnetworking afnetworking-3

我有这样的请求网址:

https://myserver.com/api/news/?offset=0?

在参数dict中,我这样传递:

  

@ {@" offset" :@(0)}

为什么我的请求结束时出现问号,如何摆脱它?

请求后我记录了这样的完整信息:

  NSLog(@"%@ | URL - %@?%@", sessionDataTaskGETReq.originalRequest.HTTPMethod,
                  sessionDataTaskGETReq.originalRequest.URL,
                  [[NSString alloc] initWithData:sessionDataTaskGETReq.originalRequest.HTTPBody encoding:NSUTF8StringEncoding]);

在这里,我在最后看到了这个额外的问号。

我的请求和响应序列化程序如下所示:

  AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer];
    [requestSerializer setValue:@"application/json, multipart/form-data, @text/html" forHTTPHeaderField:@"Accept"];

    AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer
                                                       serializerWithReadingOptions:NSJSONReadingAllowFragments];;
    responseSerializer.acceptableContentTypes = [NSSet setWithArray:@[@"multipart/form-data", @"text/html", @"text/json", @"application/json"]];

1 个答案:

答案 0 :(得分:2)

NSLog(@"%@ | URL - %@%@", sessionDataTaskGETReq.originalRequest.HTTPMethod,
                  sessionDataTaskGETReq.originalRequest.URL,
                  [[NSString alloc] initWithData:sessionDataTaskGETReq.originalRequest.HTTPBody encoding:NSUTF8StringEncoding]);

只需删除您在NSLog中添加的问号