vscode-restclient: Header name must be a valid HTTP token ["{"]

I had a previous simple test file that was working I tried to add a couple of requests in the same file but now I just get the error above on any request…

I tried reverting any changes to the .http file but still the extension just gives this invalid error each time i try to load a resource.

  • VSCode Version: Version: 1.38.1

  • OS Version: OSX 10.14.6

  • REST Client Version: 0.22.2

Steps to Reproduce:

  1. make a file with some simple tests like
POST http://localhost:55200/test HTTP/1.1
content-type: application/json
{
    "cname": "weile"
}

all will work fine. wait a while. do something? then error occurs:

  1. try and run click ‘send request’

error message pops up as toast.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 21
  • Comments: 25 (2 by maintainers)

Most upvoted comments

OK looks like the error is:

POST http://localhost:55200/test HTTP/1.1
content-type: application/json
{
    "cname": "weile"
}

where as this is OK:

POST http://localhost:55200/test HTTP/1.1
content-type: application/json

{
    "cname": "weile"
}

so the extra line is critical. a bit of a pedantic bug…

Error text about the blank line in message box should be clear.

@dcsan this follows the rules in RFC, and there should be a separated blank line between header and body parts.

i dont understand well how to fix this error

@AleksandrIvanov9655 Leave an empty line between your request headers and request body

Just so that a newbee gets it,

GET http://localhost:3099/subscribers GET http://localhost:3099/subscribers while following code will not `GET http://localhost:3099/subscribers

GET http://localhost:3099/subscribers`

@Huachao - Would you be willing to reopen this issue for the purpose of clarifying the error message that is sent to the user? That seems to be the greatest desire on the part of the people that have contributed to this thread. Yes, I understand that it is RFC compliant to have the blank line there, but the problem is that many users are spending hours trying to troubleshoot a very ambiguous error message.

What I think we would all love to see is a helpful message during the validation process before the request fires. It seems like this could be a simple RegEx expression to confirm that there is indeed a blank line between the headers and the body. If not, a message could be shown to the user.

Invalid Request Format: Please include a blank line between the header and body of the request.

This simple validation could save a huge amount of frustration for new users that are using this tool for the first time.

Thank you for your consideration!!!

For anyone else that is browsing this thread, please add your upvote if you think this would be a helpful addition! 😄

This is closed, but I am bumping this because the error message should be clear, because currently it’s not, I had to search here to figure it out.

image

change to : image

Before

Screen Shot 2021-09-25 at 1 00 27 pm

After removing space between POST and content-type fixed the issue of internal server error

Screen Shot 2021-09-25 at 12 59 04 pm

e

Remove the blank line between request url line and content type header line

Before Screen Shot 2021-09-25 at 1 00 27 pm

After removing space between POST and content-type fixed the issue of internal server error Screen Shot 2021-09-25 at 12 59 04 pm e

POST http://localhost:55200/test HTTP/1.1

content-type: application/json { “cname”: “weile” }

Inserta un salto de línea luego de la primera, eso me funcionó

@joyfullservice Thank you! Your answer is working.