Arzybek
Arzybek

Reputation: 782

Why simple json request body in Postman is not working

Can someone explain to me why this request is not working and showing me "invalid character" at colon! enter image description here

Upvotes: 4

Views: 27648

Answers (3)

Miljkoyu
Miljkoyu

Reputation: 129

In Headers tab must be checked

  1. Content-Type
  2. Content-Length

Upvotes: 7

PDHide
PDHide

Reputation: 19929

enter image description here

You have copied the json body from browser or other non standard text editor so the asci character for "," is not the actually one. it got resolved into something else . Just delete it and replace that comma and double quotes with correct correctors.

{
  "message":"hi",
  "tg_chat_id": "5"
}

Also in postman you can press ctrl+b to format and remove space , (that's not the reason for error though)

Upvotes: 5

Salahuddin Ahmed
Salahuddin Ahmed

Reputation: 5640

The POST URL you are using might be wrongly written. 400 typically means you passed something invalid to the API. This error message tends to be pretty helpful when it comes to figuring out what is wrong.

Just try keeping a single Key Value pair in Headers like Content-Type application/json.

Body->raw->JSON selection looks okay.

JSON should be like this:

{
  "message":"hi",
  "tg_chat_id":"5"
}

Upvotes: -1

Related Questions