Featured post
How to get data from a json-rpc webservice : iPad /iPhone / Objective C -
i'am working on ipad project , project needs talk json-rpc webservices. webservices based on drupal module : cck , views
1)i need push json object webservice 2)i need callback data webservice
i have implemented sbjson api , https://github.com/samuraisam/deferredkit/ api ipad project.
the sbjson api works fine , understand 1 samuriaisam defferedkit new me
my question how data out of json-rpc webservice, has sample code? or places can find objective c - json-rpc webservice documentation.
kind regards,
bart schoon
---------update--------
i use 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]; //data returned webservice nsdata *returndata = [nsurlconnection sendsynchronousrequest: request returningresponse: nil error: nil ]; nsstring *returnstring = [[nsstring alloc] initwithdata:returndata encoding: nsutf8stringencoding]; nslog(@"output: %@",returnstring);
this result in message server:
{"error":{"name":"jsonrpcerror","code":-32600,"message":"the received json not valid json-rpc request"},"version":"1.1"}
---------/update--------
what wrong? has experience this?
kind regards,
bart schoon
read json file data.
nsdictionary *dictionary = [jsonstring jsonvalue]; key & value pair. store data in respective variable.
- Get link
- X
- Other Apps
Comments
Post a Comment