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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:13:26+00:00 2026-06-01T12:13:26+00:00

I’m trying to POST data from an iOS app to Node.js/Express. I cannot get

  • 0

I’m trying to POST data from an iOS app to Node.js/Express. I cannot get it to work; Node/Express just appears to ignore my request when I try from my app. However, if I navigate to the same URL I’m trying to POST to in a web browser, Node/Express responds.

This is my Node/Express code that handles the incoming request:

var express = require('express');

var app = express.createServer();
app.configure(function(){
  app.use(express.bodyParser());
});

app.get('/', function(req, res) {
        res.write('nothing to see here...');
        res.end();
});

app.get('/test', function(req, res) {
        console.log('handling post!');
        console.log(JSON.stringify(req.body));
        res.end();
});

And this is how I’m trying to POST JSON to Node:

// Create request data.
NSString* jsonData = @"{\"test\" : \"someMoreTest\"}";
NSData* requestData = [jsonData dataUsingEncoding:NSUTF8StringEncoding];

// Create URL to POST jsonData to.
NSString* urlString = @"http://www.mysite.com/test";
NSURL* url = [NSURL URLWithString:urlString];

// Create request.
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url]; 
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody: requestData];

// Send request synchronously.
NSURLResponse* response = [[NSURLResponse alloc] init];
NSError* error = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

// Check result.    
if (error != nil)
{
    NSLog(@"submitted request!");
}
else {
    NSString* errorLogFormat = @"request failed, error: %@";
    NSLog(errorLogFormat, error);        
}

As I mentioned earlier, if I navigate to http://www.mysite.com/test in my browser, my console output from Node is the following:
handling post!
{}

However, when I try to post from my iOS app, I get no console app – it’s almost as if Node never sees the incoming POST request. And even more baffling – I can’t get any error data on the iOS app side – the error is nil. Any ideas what I’m doing wrong here?

  • 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-01T12:13:27+00:00Added an answer on June 1, 2026 at 12:13 pm

    In Express’s routing framework, app.get() only responds to GET requests, POSTs are ignored and probably result in a 404.

    You can use post() or any() instead.

    I can’t comment on the objective C portion, but I will suggest
    Nc -l 0.0.0.0 80 {or another port)
    o see what’s going on.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.