I am working on an iPad project, and this project needs to talk to json-rpc web services. Drupal based web services with module: cck and views
1) I need to push the json object into the web service 2) I need the callback data from the webservice
I already implemented the SBJSON api and https://github.com/samuraisam/DeferredKit/ api in the iPad project.
SBJSON api works great and I understand this Samuriaisam DefferedKit is new to me
My question is how to get data from this json-rpc webservice, does anyone have any sample code? Or in some places where I can find documentation on the Objective-C web service - json-rpc.
Yours faithfully,
Bart Shuon
--------- Update --------
I am using this code now:
NSString *jsonString = @"{\"method\":\"views.get\",\"params\":{\"view_name\":\"client_list\",\"sessid\":\"xxxxxx\"},\"id\":1}"; NSString *requestString = [NSString stringWithFormat:@"%@",jsonString,nil]; NSLog(@"input: %@",jsonString); NSData *requestData = [NSData dataWithBytes: [jsonString UTF8String] length: [jsonString length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://subdomain.domain.com/services/json-rpc"]]; NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]]; [request setHTTPMethod: @"POST"]; [request setValue:@"Content-type: application/json" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:requestData];
This will cause this message to appear from the server:
{"error":{"name":"JSONRPCError","code":-32600,"message":"The received JSON not a valid JSON-RPC Request"},"version":"1.1"}
--------- / Update --------
What's wrong? Does anyone come across this?
Yours faithfully,
Bart Shuon