whatsapp-api icon indicating copy to clipboard operation
whatsapp-api copied to clipboard

Send a message via a local URL

Open NiiiYaa opened this issue 1 year ago • 2 comments

Hello, I wanted to ask if there's a way to send a message via a local URL (e.g., http://localhost:3000/...). If so, could you please provide the URL structure? Thank you in advance for your help.

NiiiYaa avatar Aug 15 '24 07:08 NiiiYaa

Hi POST to url: http://localhost:3000/client/sendMessage/ABCD -H 'x-api-key: <Key>' Body: { "chatId": "[email protected]", "contentType": "string", "content": "Test Message"
}

It works using https://www.usebruno.com/downloads But i'm not sure why it does not work from command prompt using curl URL rejected: Bad hostname Get methods work from the browser

Let me know if yours works from curl

Thanks

mimail786 avatar Sep 16 '24 07:09 mimail786

This works for me:

curl -X 'POST'
'http://localhost:3000/client/sendMessage/<sessionID>'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '{ "chatId": "[email protected]", "contentType": "string", "content": "Test Message" }'

Just to be on the safe side you may want to check your session status first...

curl -X 'GET'
'http://localhost:3000/session/status/<sessionID>'
-H 'accept: application/json'

I named my sessionID default so the command that I'm running is:

curl -X 'GET'
'http://locahost:3000/session/status/default'
-H 'accept: application/json'

you should receive a response like this: {"success":true,"state":"CONNECTED","message":"session_connected"}

ovargasp avatar Oct 01 '24 22:10 ovargasp