line-bot-sdk-java icon indicating copy to clipboard operation
line-bot-sdk-java copied to clipboard

PushMessage: property 'to' is invalid

Open dratha opened this issue 10 years ago • 9 comments

I tried to send a push message but I always get the following response: { "message": "The property, 'to', in the request body is invalid (line: -, column: -)" }

Where could I find the right ID of the receiver and what format should have it(String or Array)? Or is it only available for a paid account and not an developer trial?

dratha avatar Nov 24 '16 12:11 dratha

Hi, @dratha

You can get it from webhook request.

For example, events[].source.userId.

{
  "events": [
      {
        "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
        "type": "message",
        "timestamp": 1462629479859,
        "source": {
             "type": "user",
             "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
         },
         "message": {
             "id": "325708",
             "type": "text",
             "text": "Hello, world"
          }
      }
  ]
}

be-hase avatar Nov 24 '16 12:11 be-hase

Ok. Thanks.

dratha avatar Nov 24 '16 12:11 dratha

You can see here whether you can use the push API. Thanks. :)

https://admin-official.line.me/

ss 2016-11-24 21 46 21

be-hase avatar Nov 24 '16 12:11 be-hase

I want to push message but i dont know user id of my followers. how can i get user id of followers/friends so i can send them push message? thank you

kimberly96 avatar Oct 18 '17 09:10 kimberly96

@ffebri You can get user friends userId from webhook. When user add bot as friends and talk to your bot, you can get webhooks, which are delivered to your registered url. Except webhooks, currently you cannot get any userIds.

krrrr38 avatar Oct 19 '17 14:10 krrrr38

@krrrr38
do you mean i only can get friends userId if they talk to my bot? what if they never talk and just read my message?

kimberly96 avatar Oct 20 '17 09:10 kimberly96

@ffebri Generally you collect userIds when adding bot as a friend. If already friends, require user actions such as talk to your bot. User actions contains, follow as a friend, invite to group, talk and so on, which doesn't include read message.

krrrr38 avatar Oct 20 '17 09:10 krrrr38

@krrrr38 ok, thanks a lot.

kimberly96 avatar Oct 20 '17 09:10 kimberly96

can we get the user ID by entering the user by himself?

Because I don't predict the user list, the system needs to send line messages related to the user who registers the system with the line user ID.

zaymgmgmyint avatar Nov 02 '23 04:11 zaymgmgmyint