Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PushMessage always return 400 Bad Request #54

Closed
chegola opened this issue Nov 6, 2016 · 2 comments
Closed

PushMessage always return 400 Bad Request #54

chegola opened this issue Nov 6, 2016 · 2 comments
Assignees

Comments

@chegola
Copy link

chegola commented Nov 6, 2016

I am using Line official account for free plan. I have enabled message API and EchoApplication is working fine.
I am trying to use PushMessage api from LineMessagingService but I always get return 400 Bad Request with invalid property 'to', here is full detail.

: {"to":"xxxx","messages":[{"type":"text","text":"hello"}]}
: --> END POST (61-byte body)
: <-- 400 Bad Request https://api.line.me/v2/bot/message/push (209ms)
: Server: nginx
: Content-Type: application/json;charset=UTF-8
: X-Line-Request-Id: 22701bcd-d412-4515-a16e-ea3c20956532
: X-Content-Type-Options: nosniff
: X-XSS-Protection: 1; mode=block
: X-Frame-Options: DENY
: Content-Length: 85
: Expires: Sun, 06 Nov 2016 05:11:35 GMT
: Cache-Control: max-age=0, no-cache, no-store
: Pragma: no-cache
: Date: Sun, 06 Nov 2016 05:11:35 GMT
: Connection: close
: {"message":"The property, 'to', in the request body is invalid (line: -, column: -)"}

Note: for user id 'xxxx" I have tried to use my personal line id which got from LINE application and also this account already added my Line official account.

here is code section

private void pushTextMessage() {
System.out.println("push text message:");
Message textMessage = new TextMessage("hello");
PushMessage pushMessage = new PushMessage("xxxx", textMessage);
lineMessagingService.pushMessage(pushMessage);
try {
final BotApiResponse apiResponse = lineMessagingService.pushMessage(pushMessage).execute().body();
} catch (Exception e) {
System.out.println(e.getMessage());
}

So I am not sure that

  1. Did I supply the wrong userId? if so where/how should I get a userId to supply the property 'to'
  2. How/which api should I use for sending message to all users who have added my LINE official account as friend. Because push message api still require to supply only 1 userId/time.
    Documents also said that it can send to rooms or groups but how do I get those IDs? This is just like LINE@ manager which is able to compose a message then send to friends at once.
@chegola
Copy link
Author

chegola commented Nov 7, 2016

I think the right userId should be grabbed from JSON object which contains events generated on the LINE platform, not from the LINE application, as well as groups or rooms. Even I have not tried this yet but I am closing this issue. In case the userID that grabbed from JSON object does not work, this issue could be re-open again.

Thanks.

@chegola chegola closed this as completed Nov 7, 2016
@dratha
Copy link

dratha commented Nov 24, 2016

I have the same problem but i can't find the right userID.
Where have you found the ID of the receiver?
And is it a number or a String?

Thanks.

kumai pushed a commit to kumai/line-bot-sdk-java that referenced this issue Nov 29, 2016
…eptor

Hide authorization header interceptor
georgexxu added a commit to georgexxu/Line-chatbot-for-COMP3111 that referenced this issue Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants