Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-05-2011, 03:00 AM   #1 (permalink)
Ankur
 
Join Date: Jun 2010
Posts: 21
ankur.s20 is on a distinguished road
Default 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.
ankur.s20 is offline   Reply With Quote
Old 09-05-2011, 03:07 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

try
NSLog(@"stringBody:%@",stringBody);

and see if output is correct (post it if you are not sure)
__________________
dany_dev is offline   Reply With Quote
Old 09-05-2011, 04:57 AM   #3 (permalink)
Ankur
 
Join Date: Jun 2010
Posts: 21
ankur.s20 is on a distinguished road
Default

I checked that and that's a valid json, I know it's something to do with the problem mentioned at below link i.e. with drupal server.
objective c - iPhone + Drupal + JSON RPC Server problem - Stack Overflow
ankur.s20 is offline   Reply With Quote
Reply

Bookmarks

Tags
drupal, iphone, json object request, objective c

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 380
6 members and 374 guests
JackReidy, jeroenkeij, Sami Gh, tim0504, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0