Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools HTTP Basics Introduction to HTTP Sending Data with a POST Request

Olivier Van hamme
Olivier Van hamme
5,418 Points

I cannot replicate the 404 error in the video at [4:14] .

When I set the Content-Length to 30 characters — less than is required — I simply get a shortened data string back as a response instead of the 404 error :

Here is the original POST Request in the terminal on my Mac :

POST /post HTTP/1.1
Host: httpbin.org
Content-Length: 30


After pressing enter , I get back the following response :

"data": "firstname=Dorothy&language=Eng"

Notice how the original word — English — has been shortened to Eng .

I've just had the same issue here (Windows, using workspaces). I copied the input directly from the tutorial:

 POST /post HTTP/1.1                                                                                                                                                                            
Host: httpbin.org                                                                                                                                                                              
Content-Length: 30                                                                                                                                                                             

HTTP/1.1 200 OK                                                                                                                                                                                
Access-Control-Allow-Credentials: true                                                                                                                                                         
Access-Control-Allow-Origin: *                                                                                                                                                                 
Content-Type: application/json                                                                                                                                                                                                                                                                                      
Referrer-Policy: no-referrer-when-downgrade                                                                                                                                                    
Server: nginx                                                                                                                                                                                  
X-Content-Type-Options: nosniff                                                                                                                                                                
X-Frame-Options: DENY                                                                                                                                                                          
X-XSS-Protection: 1; mode=block                                                                                                                                                                
Content-Length: 269                                                                                                                                                                            
Connection: keep-alive                                                                                                                                                                         

  "args": {},                                                                                                                                                                                  
  "data": "firstname=Chris&language=Engli",                                                                                                                                                    
  "files": {},                                                                                                                                                                                 
  "form": {},                                                                                                                                                                                  
  "headers": {                                                                                                                                                                                 
    "Content-Length": "30",                                                                                                                                                                    
    "Host": "httpbin.org"                                                                                                                                                                      

Like in your case, the query input is just cut down and accepted.

1 Answer

Matt Coale
.a{fill-rule:evenodd;}techdegree seal-36
Matt Coale
Full Stack JavaScript Techdegree Graduate 17,883 Points

I was getting the same results as you where the characters were getting cut off at 30 bytes. It makes sense, per the content-length that was set, but it's confusing versus watching the video.