vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

Invalid character in header content ["authorization"]

Open SebasLealLaunchtrip opened this issue 3 years ago • 13 comments

  • REST Client Version: v0.24.6
  • VSCode Version: 1.63.0
  • OS Version: Windows 10 Pro 20H2 - 64-bit

Steps to Reproduce:

  1. Create a new .http file
  2. Add these lines: GET http://localhost:8080/api/events/v1 content-type: application/json; charset=utf-8 Authorization: Bearer A_LONG_TOKEN

Expected Return api results

Actual I see Invalid character in header content ["authorization"] image

SebasLealLaunchtrip avatar Dec 15 '21 01:12 SebasLealLaunchtrip

@SebasLealLaunchtrip could you please provide your long authorization header value?

Huachao avatar Dec 15 '21 11:12 Huachao

Invalid character in header content ["Authorization"] i got this error in postman please help me

sanivarapuharsha avatar Dec 24 '21 07:12 sanivarapuharsha

@Huachao sorry for my late reply. So, I most likely had a character issue when I copied the token from the browser console. I remember it worked with another token. I don't have the specific scenario at hand in this moment. For my side I'd close this issue. @sanivarapuharsha maybe you can also check you token string to see if it's valid.

SebasLealLaunchtrip avatar Jan 06 '22 00:01 SebasLealLaunchtrip

Most likely you CTRL + C (CMD + C) the token. Right click and select the Copy Value option instead

Screen Shot 2022-02-28 at 7 43 53 AM

caverac avatar Feb 28 '22 13:02 caverac

is it happen when we dont store bearer token in correct way in postman

ghourigeeks avatar Jun 16 '22 23:06 ghourigeeks

This actually happens when you have a token generated with characters such as (mostly) three dots '...'somewhere in the token. Postman does not know how to handle that, unfortunately, whereas jwt.io can decode the token just perfectly. You could try to produce the token using postman.

kiokogit avatar Nov 14 '22 06:11 kiokogit

Screenshot (2). actually i am getting error in the postman, when giving token. Error: Invalid character in header content ["Authorization"]

garikapati-divya avatar Nov 30 '22 04:11 garikapati-divya

Check your Token. It is a token issue.

abaghum avatar Jan 11 '23 00:01 abaghum

I was getting this when the token ended with a newline \n

bensums avatar Feb 12 '23 09:02 bensums

Most likely you CTRL + C (CMD + C) the token. Right click and select the Copy Value option instead

Screen Shot 2022-02-28 at 7 43 53 AM

@caverac Thank you for making it work. So why doesn't "ctrl + C" work?

AnnaMadsenKnowit avatar Mar 27 '23 06:03 AnnaMadsenKnowit

Most likely you CTRL + C (CMD + C) the token. Right click and select the Copy Value option instead Screen Shot 2022-02-28 at 7 43 53 AM

@caverac Thank you for making it work. So why doesn't "ctrl + C" work?

I just had this issue, and indeed there was a newline character at the end of my token. The reason this happens when you use Ctrl+ C is that when you highlight the text, sometimes it picks up a line break, sometimes it doesn't. If you don't want to generate a new token, you can also try just removing any whitespace at the end of your token, wherever it's stored.

I was able to remove the newline character from my token and it started working!

johallorb avatar Jul 11 '23 00:07 johallorb

It is worth all the energy to configure variables in your postman environment, that can even be set directly from login api; by running tests after calling login, instead of using browser copied tokens. Its faster and avoids these inconveniences, and permanent, at least as long as you have the environment.

kiokogit avatar Jul 11 '23 03:07 kiokogit