Passing parameter in url for GET method using afnetworking

空扰寡人 提交于 2019-11-29 08:19:33

It looks like there are a number of issues with the URL you're constructing, and the way you're passing (or not passing) parameters into AFNetworking. You don't need to construct your query string yourself, as AFNetworking will do that for you. As mentioned in my comment above, passing query=where UserName='abc' as part of a URL seems like a bad idea. However, here's a quick example of how you'd call AFNetworking's GET method if your URL was slightly different:

// URL format: https://<BASE_URL>/<TENANT_URL>/?username=abc&companyId=&page=1&pageSize=25&filterResultByColumns=true

NSURL *baseURL = [NSURL URLWithScheme:@"https" host:BASE_URL path:TENANT_URL];

[manager GET:[baseURL absoluteString] 
  parameters:@{ @"username": @"abc",
                @"companyId": @"example",
                @"page": @1,
                @"pageSize": @25,
                @"filterResultByColumns": @YES }
     success:^(AFHTTPRequestOperation *operation, id responseObject) {
            // handle success
            }
     failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            // handle failure
            }];

If you pass your parameters into the GET method, AFNetworking will construct the query string for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!