2016-11-08 3 views
-1

하나의 API 끝점에서 JSON 형식의 일부 데이터에 대해 HTTP GET 요청을하고 다른 API 끝점으로 다시 POST하는 방법.API에서 JSON으로 HTTP GET 받기

+1

(무효) 대해 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

+0

[How to Ask] (http://stackoverflow.com/help/how-to-ask)를 검토하고 [Minimal, Complete, Verifiable example] (http://stackoverflow.com/help/mcve) 제공을 고려하십시오.) – David

+0

코드 조각을 제공하거나 지금까지 시도한 것을 설명하십시오. – captainsac

답변

-1

- 당신은 다른 질문이 너무 광범위 것에 대해 삭제 광석 무시 될 수있는 지역 사회의 도움을 원하는 경우 당신은 당신이 시도 코드를 포함해야한다