Skip to content

Instantly share code, notes, and snippets.

@obense
Created March 10, 2016 17:12
Show Gist options
  • Save obense/a323ba40ef7a7a989588 to your computer and use it in GitHub Desktop.
Save obense/a323ba40ef7a7a989588 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"x-accept-version": @"v1",
@"cache-control": @"no-cache",
@"postman-token": @"ca7b45bd-65b8-e9db-3a16-64f7f0efe546",
@"content-type": @"application/x-www-form-urlencoded" };
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"jobber_step_two[phone]=0671604566" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&jobber_step_two[zipcode]=13700" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://recette.ejobber.bleuroy.fr/api/jobbers/5/step2"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment