ios - AFNetworking showing unsupported URL for http get operation? -


right using latest afnetworking library perform http operation getting unsupported url error message

but when same, hitting in browser getting data

https://abc.xyz.com/status?id={"request":["123"," 456"]}

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager];     [manager get:baseurlwithstatusinformation       parameters:statusid          success:^(afhttprequestoperation *operation, id responseobject) {              nslog(@"json: %@", responseobject);          } failure:^(afhttprequestoperation *operation, nserror *error) {              nslog(@"error: %@", error);          }]; 

so here baseurlwithstatusinformation https://abc.xyz.com/status?id=

and statusid {"request":["123"," 456"]} i.e. dictionary containing array.

seems parameters should be:

@{@"id": @"{\"request\":[\"123\",\" 456\"]}"} 

and baseurlwithstatusinformation (presumably called baseurl):

https://abc.xyz.com/status 

since have mix of query string , json there. afnetworking won't both. believe.

suggested code:

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; id url = @"https://abc.xyz.com/status"; id params = @{@"id": @"{\"request\":[\"123\",\" 456\"]}"}; [manager get:url parameters:params success:^(afhttprequestoperation *operation, id responseobject) {     nslog(@"json: %@", responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) {     nslog(@"error: %@", error); }]; 

edit: it's worth checking server wants, mix of json , query string format little strange. possibly parameters should instead be:

@{@"id": @{@"request":@[@"123", @"456"]}} 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -