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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:41:43+00:00 2026-05-30T16:41:43+00:00

Searching the web for some method to send POST requests in Objective-C, I came

  • 0

Searching the web for some method to send POST requests in Objective-C, I came up with some solutions.

That’s what I’ve got:

responseData = [NSMutableData new];
NSURL *url = [NSURL URLWithString:@"http://mydomain.com/page.php?"];
NSString *myParameters = [[NSString alloc] initWithFormat:@"str=hello"];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

[request setHTTPMethod:@"POST"];
[request setHTTPBody:[myParameters dataUsingEncoding:NSUTF8StringEncoding]];

The response I receive is an error, because the POST variable “str” hasn’t been set.

What am I doing wrong?

  • 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-30T16:41:44+00:00Added an answer on May 30, 2026 at 4:41 pm

    It looks like your parameters are intended to be URL parameters (typically in name1=value1&name2=value2 form). You usually don’t want to put them in the HTTP body like you are currently doing. Instead, append them to your URL:

    NSString *requestStr = @"hello";
    NSString urlString = [NSString stringWithFormat:@"http://mydomain.com/page.php?str=%@", requestStr];
    NSURL *url = [NSURL URLWithString:urlString];
    

    NSURLRequest doesn’t provide a more generic way to do this, although you can look at this SO question and its answers for ideas on how many people deal with this kind of requirement. There are also free and/or open source libraries out there that aim to make this kind of request easier to code.

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

Sidebar

Related Questions

I have a page that uses jQuery's $.post() method to get some html and
In searching the web I came across http://groupaware.mobi/iphone which has a sample iphone navigation
Based on some standard web searching, I have narrowed down my problem to this:
I'm working on developing new Spring web applications, on a team that's developed a
I have been searching everywhere on the web and trying everything that I can
I'm trying to use R to grab some web data that requires OAuth authentication.
I've spent hours searching the web for an answer to this question... Here's what
What is the Java equivalent of PHP's $_POST ? After searching the web for
I am searching for a web service which can record the actions done by
I've been searching around the web on how to code syntax highlighting text boxes

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.