Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid character in header content ["Host"] Postman

When i try to test api with localhost:[port] it gives the invalid character in header ["Host"] console error. I am using dotnet core webApi. I cross checked the CORS configuration from api end it is fine. The issue is on the Postman side. Postman version: v8.7.0

I have attached the screenshot of the issue

like image 210
Atif Khattak Avatar asked Nov 06 '22 01:11

Atif Khattak


1 Answers

I had the same error being reported for any forked or created Postman requests:

Error: Invalid character in header content ["Host"]

The request URL was using a global parameter:

{{BaseUri}}/some/sort/of/resource

In the console logs the following was reported (URLs redacted):

Request Headers
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 9d14e81d-1e21-44a2-93ed-2758f0ad24fa
Host: my.url.co.uk↵
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

Note the ↵ character at the end of the Host Header.

The global BaseUri parameter did not appear to have a line break at the end of it. However, completely deleting said parameter and recreating it seems to have fixed the issue.

like image 196
Paul Robson Avatar answered Nov 14 '22 21:11

Paul Robson