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 8694655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:50:11+00:00 2026-06-13T00:50:11+00:00

I intend to post json data : NSString *newJSON = [theDictionary JSONRepresentation]; NSURL *url

  • 0

I intend to post json data :

NSString *newJSON = [theDictionary JSONRepresentation];

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:ADDRESS,action]];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request appendPostData:[newJSON dataUsingEncoding:NSUTF8StringEncoding]];

[request startSynchronous];
NSString *responseString = [request responseString];

NSMutableDictionary* responseDict = [responseString JSONValue];
NSLog(@"responseString = %@",responseString);

does the code work?did I miss some code?
I read the asihttprequest tutorial,and find it always post data with asiformdatarequest,what’s the difference between asihttprequest and asiformdatarequest,if I just want to post json data,what should I do?thank you in advance.

UPDATE:yes,it works,but don’t work well,I use some tool test the data,and receive some extra data:

POST / HTTP/1.1
Host: 192.168.0.113
User-Agent: Ushi.com/1.0 CFNetwork/548.1.4 Darwin/11.3.0
Content-Length: 58
  • 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-13T00:50:12+00:00Added an answer on June 13, 2026 at 12:50 am

    You can post text data in json format like this

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    
    [request setRequestMethod:@"POST"];
    [request addRequestHeader:@"Accept" value:@"application/json"];
    [request addRequestHeader:@"content-type" value:@"application/x-www-form-urlencoded"];
    [request addRequestHeader:@"User-Agent" value:@"iPad"];
    

    API itself sets user-agent although you can set it yourself too

    request.allowCompressedResponse = NO;
    request.useCookiePersistence = NO;
    request.shouldCompressRequestBody = NO;
    [request setPostBody:[NSMutableData dataWithData:[jsonRequest  dataUsingEncoding:NSUTF8StringEncoding]]];
    [request startSynchronous];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to encode the params to ISOLatin which i intend to post to
I intend to have a busy waiting spinner as per shown in this post:
i intend to use JSON to implement a client server communication. My goal is
I'm working on cookie-free session, I dont intend to pass variables through URL, but
I've created a WCF service which I intend to use when sending data from
I have code to Post data in server , this is my code List<NameValuePair>
be kind this is my first post. I have a Crop intent retuning and
I intend to convert a physical book into a ebook for iPhone. I am
I intend to create a realtime counter. So one user can incremenet the counter
I intend to change certain features/functions in Emacs. I was wondering whether there is

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.