Missing carriage return character '\r' in request body causes 400 Bad Request

I’ve been struggling with this for days and feel like I’m losing my mind. I’ve 2 identical requests 1 returns a 200 OK and the other returns a 400 Bad Request. I sniffed the requests in Postman console and discovered that the 200 request has Content-Length 1982 while the 400 request has Content-Length 2026.

I exported the collections associated with each request as JSON and figured that the 200 request body had \r\n as a line terminator while the 400 request body has \n as a terminator line. I presume this accounted for the difference between the 2 Content-Lengths above.

I replaced each \n with \r\n in the 400 JSON file and imported it back in Postman and ran the request again only to get a 200 which is great but doesn’t explain why lack of \r would cause a 400 Bad Request.

The request is MTOM SOAP Example MTOM SOAP Request for the CheckInAAF Operation · GitHub

I presume the request wasn’t “interpreted” into the correct format because of a lack of \r

@tafadzwagonera, on checking your sample payload and your query. Basically \n, \r is used to denote a new line, and it depends on the interpreter how it interprets. The reason you got the error 400(Bad request) depends on how your target service is configured. I just found one query on stackoverflow which contains useful information regarding these new line characters.

Hope this helps.

1 Like

@darkphoenix I’ve just read the linked SO answer. There are all sorts of useful explanations there. This has been helpful.