-1
如何从一个API端点对JSON格式的某些数据执行HTTP GET请求并将其POST回另一个API端点。API中的JSON HTTP GET
如何从一个API端点对JSON格式的某些数据执行HTTP GET请求并将其POST回另一个API端点。API中的JSON HTTP GET
- (空)的GetRequest {
//Init the NSURLSession with a configuration
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
//Create an URLRequest
NSURL *url = [NSURL URLWithString:@"Your URL"];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
//Create task
NSURLSessionDataTask *dataTask = [defaultSession dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
//Handle your response here
// NSLog(@"resultsDictionary is %@",response);
}];
[dataTask resume];
}
,如果你想从社区否则你的问题可能被忽略矿石删除了范围过宽帮助你应该包括你已经尝试过的代码.. – ted
请查看[如何提问](http://stackoverflow.com/help/how-to-ask)并考虑提供[最小,完整和可验证的示例](http://stackoverflow.com/help/mcve ) – David
提供您的代码片段或解释您到目前为止尝试过的内容 – captainsac