Unable to send json object while sending request to drupal server
I am writing an iPhone app and trying to send a POST request to drupal server with a JSON object but it always returns me {"#error":true,"#data":"Invalid method I tried following: NSMutableURLRequest *urlReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xxxxxxx/services/json"]];
[urlReq setHTTPMethod:@"POST"];
[urlReq setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *stringBody = @"{data:{\"method\":\"views.get\",\"view_name\":\" words\",\"args\":[\"wod_businessspotlight\"],\"limit\":365}}";
NSData *dataBody = [stringBody dataUsingEncoding:NSUTF8StringEncoding];
[urlReq setValue:[NSString stringWithFormat:@"%d", [dataBody length]] forHTTPHeaderField:@"Content-Length"];
[urlReq setHTTPBody:dataBody];
NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:urlReq delegate:self];
[con start];
I have seen a similar problem at "http://stackoverflow.com/questions/2596324/iphone-drupal-json-rpc-server-problem" but it doesn't mention Where can I find SBJSON class and JSONFragment method. Also I have downloaded https://github.com/stig/json-framework/ but couldn't find JSONFragment method anywhere.
Please help me out of this. Thanks In advance.
|