Riko80 | 2023-02-23 14:28:54 UTC | #1
Hi, I want to send an agentless whatsapp from the developper tools tab "send an agentless whatsapp I get this error message : { "message": "This request requires a non-user context. User token cannot be used for requests to this resource.", "code": "not.a.client", "status": 400, "contextId": "7c3ecf32-c536-4816-aab0-cffdf9470408", "details": [], "errors": [] }
this is below my request :
/api/v2/conversations/messages/agentless
{
"fromAddress": "81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0",
"toAddress": "212XXXXXXXXXX",
"toAddressMessengerType": "whatsapp",
"textBody": "",
"messagingTemplate": {
"responseId": "",
"parameters": [
{
"id": "",
"value": ""
}
]
},
"useExistingActiveConversation": true
}
How can I solve this problem to send an agentless whatsapp please?
Regards
Eos_Rios | 2023-02-23 14:42:40 UTC | #2
Off hand I'd say you'll need to generate an OAuth token and use Postman or Insomnia or similar. Some things can't be done by a user, some things can only be done a user.
The API is clear on this;
Send an agentless outbound message. Send an agentless (api participant) outbound message using a client credential grant. In order to call this endpoint you will need OAuth token generated using OAuth client credentials authorized with at least messaging scope. This will generate a new Conversation, if there is an existing active Conversation between the fromAddress and toAddress already, then this POST will fail.
tim.smith | 2023-02-23 14:47:27 UTC | #3
Riko80, post:1, topic:18553
How can I solve this problem to send an agentless whatsapp please?
You will need to implement the client credentials grant in your application or use a local tool like postman to test it. Client credentials are never able to be used in a browser under any circumstances.
Riko80 | 2023-02-23 14:52:49 UTC | #4
Thank you for your update,
What type of OAUTH should I choose? once this OAUTH generated how should I implement it with the developper tools part? I have never used postman, is there a place where I should declare OAUTH? Regards
Riko80 | 2023-02-24 07:54:46 UTC | #5
@tim.smith, Thank you for your update,
What type of OAUTH should I choose? once this OAUTH generated how should I implement it with the developper tools part? I have never used postman, is there a place where I should declare OAUTH? Regards [/quote]
tim.smith | 2023-02-24 14:17:57 UTC | #6
Riko80, post:5, topic:18553
What type of OAUTH should I choose?
The one I linked above. Client credentials.
Riko80, post:5, topic:18553
once this OAUTH generated how should I implement it with the developper tools part?
You don't. As stated previously, client credentials are never able to be used in a browser under any circumstances.
Riko80, post:5, topic:18553
I have never used postman, is there a place where I should declare OAUTH?
Yes. https://learning.postman.com/docs/sending-requests/authorization/
Riko80 | 2023-02-27 14:24:15 UTC | #7
@tim.smith Thank you for your answer, I created Oauth of type client information on the admin side as below :
I tried to test it with insomnia but each time it gives me the " 404 bad request" error message as on the screenshot as below
Regards
Riko80 | 2023-02-27 14:24:25 UTC | #8
@tim.smith I also ran this test but got a "400 bad request" error message
Regards
tim.smith | 2023-02-27 14:25:49 UTC | #9
@Riko80 You must regenerate your client secret immediately. You have posted your org's credentials publicly on the internet. I have removed the offending screenshots, but some person/app could have scraped the values. Please review with your security team to check for unauthorized activity in your org. Client secrets must always be handled like passwords.
tim.smith | 2023-02-27 14:27:18 UTC | #10
Riko80, post:8, topic:18553
got a "400 bad request" error message
Please read the error message you're getting in the response; it tells you what is wrong. Refer to the client credentials documentation linked above for documentation on the correct format. You must send the request exactly as documented.
system | 2023-03-30 14:27:34 UTC | #11
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 18553