Active
Project:
JSONRPC Server
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2011 at 08:57 UTC
Updated:
14 Mar 2011 at 08:57 UTC
I've been trying to get this to work with an iPhone app, I'm pretty sure what I'm sending conforms to the JSON-RPC version 1.1 spec but all I get back is {"error":{"name":"JSONRPCError","code":-32600,"message":"The received JSON not a valid JSON-RPC Request"},"version":"1.1"}
The JSON I am sending looks like this without the escapes:
{
"version": "1.1",
"method": "user.login",
"params": {
"username": "****",
"password": "****"
}
}This is the Objective-C code that I have:
NSString* bodyString = @"{ \"version\": \"1.1\", \"method\": \"user.login\", \"params\": {\"username\": \"****\", \"password\": \"****\"}}";
NSData* body = [bodyString dataUsingEncoding: NSUTF8StringEncoding];
NSNumber *bodyLength = [NSNumber numberWithInt: [body length]];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://*******/services/json-rpc"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"ios app" forHTTPHeaderField:@"User-Agent"];
[request setValue:@"application/json-rpc" forHTTPHeaderField:@"Content-Type"];
[request setValue:[bodyLength stringValue] forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json-rpc" forHTTPHeaderField:@"Accept"];
[request setHTTPBody:body];
NSData* response = [[[NSURLConnection sendSynchronousRequest:request returningResponse: nil error: nil] retain] autorelease];Any idea what could be wrong?