daleijn
daleijn

Reputation: 738

Remove question mark at the end of the query in AFNetworking 3 GET request

I have request URL like this:

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

In parameters dict I pass it like this:

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

Why question mark at the end of my request appears, and how can I get rid of it?

After request I logging it's full info like this:

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

And here I see this additional question mark at the end.

My request and response serializers looks like this:

  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"]];

Upvotes: 0

Views: 266

Answers (1)

Bassam
Bassam

Reputation: 856

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

just remove your question mark you added in NSLog

Upvotes: 2

Related Questions