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

  • SEARCH
  • Home
  • 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 1090437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:22:22+00:00 2026-05-16T23:22:22+00:00

Hey, I need to make a HTTP POST request with an array of NSDictionary

  • 0

Hey, I need to make a HTTP POST request with an array of NSDictionary objects.

When I do this, however, I notice on the server side that the NSDictionary object does not get deserialized to a hash. It gets deserialized to a string – which is not what i want.

This is how I send the parameter from the client (IPhone) side:

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
for (ABContact *c in contactsWithEmailsOrPhones){
  NSString *phoneNumber = [[ABContactsHelper class] contactPhoneNumber:c];
  NSString *email = [[c emailArray] objectAtIndex:0];
  NSLog(@"looping: %@, %@", phoneNumber, email);
  NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                         phoneNumber,
                         @"phone", 
                         email,
                         @"email", 
                         [c firstname],
                         @"firstname",
                          [c lastname],
                          @"lastname", nil];

    [request addPostValue:dict forKey:@"contacts[]"];
}

[request setDelegate:self];
[request startAsynchronous];

This is how it looks when it is deserialized on the server (rails) side:

Started POST "/app/find_friends" for 67.164.97.48 at Thu Sep 23 14:40:37 -0700 2010
Processing by app#find_friends as HTML
Parameters: {"contacts"=>["{\n    email = \"xx\";\n    firstname = xx;\n    lastname = xx;\n    phone = \"xx\";\n}", "{\n    email = \"xx\";\n    firstname = xx;\n    lastname = xx;\n    phone = \"xx\";\n}"]}
Completed 200 OK in 0ms (Views: 0.3ms | ActiveRecord: 0.0ms)

I am sure this is a common problem that people face. So there definitely is a solution for this.

Thanks in advance for all the comments/answers.

  • 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-05-16T23:22:23+00:00Added an answer on May 16, 2026 at 11:22 pm

    Firstly, to explain what you’re seeing:

    The addPostValue method is designed to take a single value, and calls [value description] to convert that value into a string. The description method gives a string representation, which is what you’re seeing on the server side (the description method is also what NSLog calls if you pass an object to it, so the format should look quite familiar). So the iphone has being asked to send a string, and does so, and the server is “correctly” showing that as a string.

    If you just want to send a single contact, then just call ‘addPostValue’ for each key/value pair – ie. once for phone, again for email, etc.

    If you want to pass multiple contacts you probably need something better. I’m not really familiar with ruby-on-rails so there may be other solutions, but certainly a common way to pass more complex data structures to webservices from the iphone is to use json.

    There’s a json library for the iphone here:

    http://code.google.com/p/json-framework/

    and ruby on rails has built in json support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I'm using php 5 and need to communicate with another server that runs
Hey guys my current menu is like this: I need to make it so
Hey guys, I need to make a list of some functions that are listed
Hey i need help with this server status script. What is happening is when
Hey i need to make a count on a few tables where i have
Hey all, my first post :D Problem: I'm trying to make a template gallery,
For this code i need to take a string like <b>hey</b> more text<b>hey2</b> other
Hey all. I'll try to make this brief and simple. :) I have 40
Hey there, i am trying to make a little app that will serve multiple
Hey I need to make my tableview cells size to adjust by the amount

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.