Reputation: 229
Already i used the POST with Restkit is working fine. But i don't know what is difference between POST and PUT in Restkit. I just changed the method type only to "PUT". But my parameter is not sending to Webservice.
Below is my code, the same code for POST is working to me.
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:URL];
[client setDefaultHeader:@"Authorization" value:[DSUserDefaults user].accessToken];
NSDictionary *prefDict=[NSDictionary dictionaryWithObjectsAndKeys: @"",@"COMPANY_ID" ,@"",@"JOBTITLE",@"2",@"JOBTYPE" ,@"San Franscisco, US",@"LOCATION", nil];
NSLog(@"prefDict %@",prefDict);
NSMutableURLRequest *request = [client requestWithMethod:PUT path:@"" parameters:prefDict];
[request setURL:URL];
[request setTimeoutInterval:60.0];
[request setHTTPMethod:PUT];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[AFHTTPRequestOperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(100, 500)]];
[operation setCompletionBlockWithSuccess: ^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"operation.responseString: %@", operation.responseString);
NSData *data =[operation.responseString dataUsingEncoding:NSUTF8StringEncoding];
}
How to send "text" data to request. I don't need to send as dictionary.
Upvotes: 0
Views: 237
Reputation: 119031
PUT and POST aren't different settings in RestKit, they are different HTTP upload type settings which are passed into the URL request that will be sent. As such, they are handled by the server. If the server isn't configured to handle them then you will not get the expected functionality. GET and POST are relatively common, PUT is less common so may not be covered in your server implementation.
See here for details on POST, PUT and GET.
Upvotes: 1