[GH-ISSUE #649] Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '' is not a valid HTTP header field name. #229

Closed
opened 2026-03-16 14:09:02 +03:00 by kerem · 2 comments
Owner

Originally created by @codeasashu on GitHub (Mar 5, 2020).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/649

Describe the bug
Unable to set application/x-www-form-urlencoded as Content-Type header. Setting this header gives me HTTP status code 500, however cUrl is working for the same.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Home'
  2. Enter 'application/x-www-form-urlencoded' in 'Content-Type' header section
  3. Send the POST request to https://httpbin.org/post
  4. Response status gives following error: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '' is not a valid HTTP header field name.", with HTTP status code 500.

Expected behavior
The response should be same as the output of cUrl curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded' http://httpbin.org/post

{
  "args": {},
  "data": "",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Content-Type": "application/x-www-form-urlencoded",
    "Host": "httpbin.org",
    "Referer": "",
    "User-Agent": "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
    "X-Amzn-Trace-Id": "Root=1-5e6090d9-0b751e5ac119b94d699aa887"
  },
  "json": null,
  "origin": "182.76.138.139",
  "url": "http://httpbin.org/post"
}

Desktop (please complete the following information):

  • OS: MacOS catalina
  • Browser: Google Chrome
  • Version: Version 80.0.3987.122 (Official Build) (64-bit)

Additional context
I am using https://postwoman.io/ to test this.

Originally created by @codeasashu on GitHub (Mar 5, 2020). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/649 **Describe the bug** Unable to set `application/x-www-form-urlencoded` as `Content-Type` header. Setting this header gives me HTTP status code 500, however cUrl is working for the same. **To Reproduce** Steps to reproduce the behavior: 1. Go to 'Home' 2. Enter 'application/x-www-form-urlencoded' in 'Content-Type' header section 3. Send the `POST` request to `https://httpbin.org/post` 4. Response status gives following error: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '' is not a valid HTTP header field name.", with HTTP status code 500. **Expected behavior** The response should be same as the output of cUrl `curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded' http://httpbin.org/post` ```json { "args": {}, "data": "", "files": {}, "form": {}, "headers": { "Accept": "*/*", "Content-Type": "application/x-www-form-urlencoded", "Host": "httpbin.org", "Referer": "", "User-Agent": "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)", "X-Amzn-Trace-Id": "Root=1-5e6090d9-0b751e5ac119b94d699aa887" }, "json": null, "origin": "182.76.138.139", "url": "http://httpbin.org/post" } ``` **Desktop (please complete the following information):** - OS: MacOS catalina - Browser: Google Chrome - Version: Version 80.0.3987.122 (Official Build) (64-bit) **Additional context** I am using https://postwoman.io/ to test this.
kerem 2026-03-16 14:09:02 +03:00
  • closed this issue
  • added the
    invalid
    label
Author
Owner

@liyasthomas commented on GitHub (Mar 5, 2020):

I couldn't reproduce the issue.

Set up 1: Set Content-Type in request section itself

Request

postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded

Response

postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded (3)

As you can see, response Content-Type is application/x-www-form-urlencoded


Set up 2: Set Content-Type in Headers section itself

Request

postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded (2)

Response

postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded (1)

As you can see, response Content-Type is application/x-www-form-urlencoded

<!-- gh-comment-id:595050520 --> @liyasthomas commented on GitHub (Mar 5, 2020): I couldn't reproduce the issue. # **Set up 1: Set `Content-Type` in request section itself** ## **Request** ![postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded](https://user-images.githubusercontent.com/10395817/75953415-50838e80-5ed7-11ea-8a7b-8df0afbd7cef.png) ## **Response** ![postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded (3)](https://user-images.githubusercontent.com/10395817/75953429-57120600-5ed7-11ea-831c-17bb2af34300.png) **As you can see, response `Content-Type` is `application/x-www-form-urlencoded`** --- # **Set up 2: Set `Content-Type` in Headers section itself** ## **Request** ![postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded (2)](https://user-images.githubusercontent.com/10395817/75953449-61340480-5ed7-11ea-94f6-459db755ca4b.png) ## **Response** ![postwoman io__method=POST url=https___httpbin org path=_post contentType=application_x-www-form-urlencoded (1)](https://user-images.githubusercontent.com/10395817/75953454-63965e80-5ed7-11ea-96ea-13cf81604aee.png) **As you can see, response `Content-Type` is `application/x-www-form-urlencoded`**
Author
Owner

@codeasashu commented on GitHub (Mar 5, 2020):

Ok weird, it works now. Don't know why it happended but seems to be fixed now. I will make sure to check for anything else I might have done to cause this issue. Thanks for taking your time to reply.

<!-- gh-comment-id:595181894 --> @codeasashu commented on GitHub (Mar 5, 2020): Ok weird, it works now. Don't know why it happended but seems to be fixed now. I will make sure to check for anything else I might have done to cause this issue. Thanks for taking your time to reply.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#229
No description provided.