Q&A

PUSH API : 400 bad request

Hi, I try to push message to a user in postman, but always get 400 bad request. url:

POST https://api.line.me/v2/bot/message/push

headers:

Content-Type : application/json
Authorization : Bearer {ChannelAccessToken}

body:

{
    "to" : "Uc83821f5e4e6XXXXXXXXXXXXXXX",
            "messages" : [
                {
                    "type" : "text",
                    "text" : "message"
                }
            ]
}

and response:

{
    "message": "Bad request"
}

The user has already added my bot(associated with ChannelAccessToken) as a friend. Im sure that the ChannelAccessToken and userID are correct, but it always return 400 bad request.

And then I try to use broadcast api (https://api.line.me/v2/bot/message/broadcast) it successfully sent and I have received a message on my phone.

did i do someting wrong or missing with push api? Please help, thanks.

  • 1
  • 3
  • 253
  • twitter facebook

It seems your request body is not good. Can you try this body?


  "to" : "Uc83821f5e4e6XXXXXXXXXXXXXXX",
            "messages" : [
                {
                    "type" : "text",
                    "text" : "message"
                }
            ]
}
  • 1

@Koki thanks for reply, I remove "{ }" in "to" and it still 400 bad request.

  • 0

I think there is no problem with your payload. In most cases I experienced that can cause the 400 status code and got the reply message "Bad Request" is about the userId. The userId is uniquely generated per one provider and it can't be used across each other.

So please make sure that your userId that you want to sent is generated from the channel in the same provider that you want to use Push API.

  • 0
本当によろしいですか? question.vm