删除 AFNetworking 3 GET 请求中查询末尾的问号
Remove question mark at the end of the query in AFNetworking 3 GET request
我有这样的请求URL:
https://myserver.com/api/news/?offset=0?
在参数字典中,我是这样传递的:
@{ @"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"]];
NSLog(@"%@ | URL - %@%@", sessionDataTaskGETReq.originalRequest.HTTPMethod,
sessionDataTaskGETReq.originalRequest.URL,
[[NSString alloc] initWithData:sessionDataTaskGETReq.originalRequest.HTTPBody encoding:NSUTF8StringEncoding]);
只需删除您在 NSLog 中添加的问号
我有这样的请求URL:
https://myserver.com/api/news/?offset=0?
在参数字典中,我是这样传递的:
@{ @"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"]];
NSLog(@"%@ | URL - %@%@", sessionDataTaskGETReq.originalRequest.HTTPMethod,
sessionDataTaskGETReq.originalRequest.URL,
[[NSString alloc] initWithData:sessionDataTaskGETReq.originalRequest.HTTPBody encoding:NSUTF8StringEncoding]);
只需删除您在 NSLog 中添加的问号