Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:16:00+00:00 2026-06-08T14:16:00+00:00

Hi guys so i am using NSJSONSerialization dataWithJSONObject:jsonDict options:NSJSONWritingPrettyPrinted error:nil] command to write the

  • 0

Hi guys so i am using NSJSONSerialization dataWithJSONObject:jsonDict options:NSJSONWritingPrettyPrinted error:nil] command to write the json. It looks fine and when i post to the Rails server the \”first name\” is still there. Can any one help

NSArray *objects = [NSArray arrayWithObjects:@"firstname", @"lastname",nil];
NSArray *keys = [NSArray arrayWithObjects:@"dave", @"lu", nil];
NSDictionary *questionDict = [NSDictionary dictionaryWithObjects:keys forKeys:objects];


NSArray *objects2 = [NSArray arrayWithObjects:@"utf8", 
                                @"authenticity_token",@"check_i_ndatum", @"commit",nil];
NSArray *keys2 = [NSArray arrayWithObjects:@"1", @"xx",questionDict,@"Create Check i 
                                                                          Nadtum", nil];
NSDictionary *jsonDict = [NSDictionary dictionaryWithObjects:keys2 forKeys:objects2];

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict 
                                          options:NSJSONWritingPrettyPrinted error:nil];


NSURL * url =[NSURL URLWithString:@"http://192.168.1.105:3000/check_i_ndata"];
 //the request

NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:url    
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
//bind req w/ json
[request setHTTPMethod:@"POST"];
//[request setValue:@"check_i_ndata" forHTTPHeaderField:@"Accept"];
[request setValue:[NSString stringWithFormat:@"%d",[jsonRequestData length]] 
forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:jsonRequestData];

NSURLResponse * response = nil;
NSError *error =nil;
NSData *reslut =[NSURLConnection sendSynchronousRequest:request 
returningResponse:&response error:&error];

OUTPUT->>>>in xcode

  {
  "commit" : "Create Check i Nadtum",
  "authenticity_token" : "xx",
  "utf8" : "1",
  "check_i_ndatum" : {
    "firstname" : "dave",
    "lastname" : "lu"
  }
}

OUTPUT ->>> ON RAILS SERVER

Started POST "/check_i_ndata" for 192.168.1.100 at 2012-07-29 10:25:37 -0700
Processing by CheckINdataController#create as */* 
Parameters: {"{\n  \"commit\" : \"Create Check i Nadtum\",\n \"authenticity_token\" : 
\"xx\",\n  \"utf8\" : \"1\",\n\"check_i_ndatum\" : {\n    \"firstname\" : \"dave\",\n
\"lastname\" : \"lu\"\n  }\n}"=>nil}

SHOULD LOOK LIKE THIS ->>> ON RAILS SERVER

{"utf8"=>"✓", "authenticity_token"=>"XtLdI2lWSfO6OL8OwZ9Kai+Cm7hFe16EH50zPfheGbs=",
"check_i_ndatum"=>{"firstname"=>"sdf", "lastname"=>"asdf",
"medicalID"=>"adsf", "checkedInDate(1i)"=>"2012",
"checkedInDate(2i)"=>"7", "checkedInDate(3i)"=>"29",
"checkinTime(1i)"=>"2012", "checkinTime(2i)"=>"7",
"checkinTime(3i)"=>"29", "checkinTime(4i)"=>"08",
"checkinTime(5i)"=>"40"}, "commit"=>"Create Check i ndatum"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:16:01+00:00Added an answer on June 8, 2026 at 2:16 pm

    You haven’t set the content type on your post request so it ends up getting interpreted as a normal form encoded post.

    Adding a Content-Type header set to something like application/json should result in rails parsing the request as json

    For example with respect to the code above this might look like:

    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys I'm a bit new in using java and i'm trying to write a
Hey guys using POSIX API system calls read , write , open , etc.
I would like to know what guys are using to make diagram of your
Hi guys I am using the Google RSS API (ATOM) to extract RSS feeds.
Hi guys I'm using this method to check if my app is in background
Guys, I am using SQL Server 2000 and executing the sp_columns stored procedure to
Hey guys (and gals) I'm having a problem using Assembly GetExportedTypes() in .NET 4.0.
Morning guys. Using C sharp .net4, and MS Visual Studio 2010. I have Developed
hi guys i'm posting some data to controller using jquery ajax, but i am
Hey guys, I'm using Twitter's PHP API, called twitterlibphp , and it works well,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.