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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:54:10+00:00 2026-06-12T03:54:10+00:00

I am trying to do a post via http with no succes here is

  • 0

I am trying to do a post via http with no succes here is my code

NSError *error;
NSHTTPURLResponse *response;

NSData *posting =
[NSJSONSerialization dataWithJSONObject:[input createJsonDictionary]
                                options:0
                                  error:&error];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", kURL]];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];

[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json"
  forHTTPHeaderField:@"Content-Type"];
[urlRequest setValue:[NSString stringWithFormat:@"AuthToken %@",token]
  forHTTPHeaderField:@"Authorization"];
[urlRequest setHTTPBody:posting];

NSData *urlResponse =
[NSData dataWithData:[NSURLConnection sendSynchronousRequest:urlRequest
                                           returningResponse:&response error:&error]];
NSDictionary *jsonDictionary =
[NSJSONSerialization JSONObjectWithData:urlResponse
                                options:0
                                  error:&error];

NSLog(@"status code: %i", [response statusCode]);

NSLog(@"URL: %@", [urlRequest URL]);
NSLog(@"header: %@ \n method: %@", [urlRequest allHTTPHeaderFields], [urlRequest HTTPMethod]);
NSLog(@"body: %@\n", [[NSString alloc] initWithData:[urlRequest HTTPBody] encoding:NSUTF8StringEncoding]);

In the NSLog I am getting back status code 500, there is a error. But when i try to do the same command using cURL

curl --request POST -H "Content-Type: application/json" 
-H "Authorization: AuthToken TOKEN" --data '{"DATA"}' -sL 
-w "\\n%{http_code} %{url_effective}\\n" https://URL.com

I get back status code 201, succes. Something seems to be off in my code. Also in the NSLogs for urlRequest they equal whats in the curl command. Is there something I’m doing incorrectly?

  • 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-12T03:54:11+00:00Added an answer on June 12, 2026 at 3:54 am

    Found my own answer. The problem was that my code was making call to the server synchronously and the servers weren’t set up to do synchronous web calls. Instead I had to use a instant variable of NSURLConnection and do the call asynchronously “sendAsynchronousRequest:queue:completionHandler:” and use the methods start/cancel with the instant variable.

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

Sidebar

Related Questions

I'm stuck trying to get a WinInet HTTP POST via SSL using ONLY C.
I am trying to submit a delete link click via a http post to
I am trying to send the data via ajax POST method my code is
i am trying to post data via HTTP Post using name value key pair.
I am trying to access textalertapp.com via HTTP Post request from my android application.
I'm trying to post to WordPress using curl via PHP - I'm posting using
I'm trying to create devise users via POST using JSON. The current code of
I am trying to send a HTTP POST via CURL on the command line.
I am trying to download a report from Datacash via an HTTP post using
I'm trying to delete a blog post on blogger.com using Blogger API via Prototype

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.