Friday, January 11, 2019

HTTP Error 400. The request has an invalid header name - Post request to D 365 F&O oData service from Fiddler

An error "HTTP Error 400. The request has an invalid header name" comes when we do Post request to D 365 F&O oData service as below from Fiddler.

Request message:
POST https:axurl/data/XXX HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: Bearer
Host: axurl
{
"@odata.type":"#Microsoft.Dynamics.DataEntities.XXX",
"dataAreaId":"YYY"
}

Error message:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 11 Jan 2019 14:54:42 GMT
Connection: close
Content-Length: 339

Bad Request

Bad Request - Invalid Header



HTTP Error 400. The request has an invalid header name.



The solution to resolve this error is just add extra space between header and body as below

POST https:axurl/data/XXX HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: Bearer
Host: axurl

{
"@odata.type":"#Microsoft.Dynamics.DataEntities.XXX",
"dataAreaId":"YYY"
}

No comments:

Post a Comment