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

The Archive Base Latest Questions

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

I’ve seen several posts related to this but none seem to be the problem

  • 0

I’ve seen several posts related to this but none seem to be the problem here.

It’s a very simple beginner nodejs app with expressjs on windows7

/**
 * Module dependencies.
 */


var express = require('express')
    , connect = require('connect')
    , http = require('http')


var app = express();

app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  // app.use(express.bodyParser());
  app.use(connect.bodyParser());
});

/**
 * Routes
 */
//get requests
// app.get("/", function(req, res){
//   res.send("Hello, Express!");
// });

// app.get("/hi", function(req, res){
//   var message = [
//     "<h1>Hello, Express!</h1>",
//     "<p>Welcome to 'Building Web Apps in Node.js with Express.'</p>",
//     "<p>You'll love Express because it's</p>",
//     "<ul><li>Fast</li>",
//     "<li>Fun</li>",
//     "<li>Flexible</li>"
//   ].join("\n");

//   res.send(message);
// });

// app.get("/users/:userID", function(req, res){
//   res.send("<h1>Hello, User #" + req.params.userID + "!");
// });

//post requests
app.post("/users", function(req, res){
    // res.send(req.body);
    res.send(req.body.username);
});


http.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});

As you can see I’ve commented out other routes just to ensure they aren’t causing the problem and I’ve also tried installing and using ‘connect’ but both express.bodyParser() and connect.bodyParser() give me the same results.

I’ve used chrome adv rest client extension and also tried the following simple php form.

<form action="http://localhost:3000/users" method="POST" enctype="application/x-www-form-urlencoded">
    <li>
        <label for="username">Username</label>
        <input type="text" name="username" id="username">
    </li>
    <li>
        <input type="submit" name="submit" id="submit">
    </li>
</form>

In all cases I get a empty or undefined req.body.username and when I try just req.body in the response I get a empty object {}

UPDATE:
Here is the response/request header info from chrome:

Request URL:http://localhost:3000/users
Request Method:POST
Status Code:200 OK
Request Headersview source
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:31
Host:localhost:3000
Request Payload
username=isimmons&submit=Submit
Response Headersview source
Connection:keep-alive
Date:Sat, 27 Oct 2012 23:01:45 GMT
Transfer-Encoding:chunked
X-Powered-By:Express

And Here is what I get when I send req.route

//result of console.log(req.route);
{ path: '/users',
  method: 'post',
  callbacks: [ [Function] ],
  keys: [],
  regexp: /^\/users\/?$/i,
  params: [] }

Node and Express versions:
express 3.0
node 0.8.9

UPDATE2 PROBLEM SEMI SOLVED
See comments below. I should have just said it here. Anyway, here is the request header info from chrome when it works correctly.

Request URL:http://localhost:3000/users
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:26
Content-Type:application/x-www-form-urlencoded
Host:localhost:3000
Origin:http://localhost
Referer:http://localhost/nodeform.php
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.16 (KHTML, like Gecko) Chrome/24.0.1305.3 Safari/537.16
Form Dataview sourceview URL encoded
username:dfd
submit:Submit
Response Headersview source
Connection:keep-alive
Content-Length:3
Content-Type:text/html; charset=utf-8
Date:Sun, 28 Oct 2012 01:12:23 GMT
X-Powered-By:Express

Thanks

  • 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-13T15:26:01+00:00Added an answer on June 13, 2026 at 3:26 pm

    Ok, finally came across this bug report for the rest api and simply adding the content-type resolved the issue.

    Bug report

    The bug report has a reply to manually add the ‘Content-type’ header before sending. This is why the php form worked. It has the enctype set so I get the complete request header as shown above.

    The correct content-type header to add manually is

    Content-Type: application/x-www-form-urlencoded
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
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
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.