MiquelTrillaRomero | 2022-05-12 16:42:28 UTC | #1
When trying to call a service i Get a 400 status response (bad request) and on headers I get this "error from cloudfront"
I already have called a previous service successfully and this is happening on the second call:
[Symbol(Response internals)]: { type: 'default', url: 'https://api.mypurecloud.ie/api/v2/conversations/messages/b6702789-b113-4682-b918-f0cd6636c983/communications/339a2f69-aaf2-48d0-9b42-b7b6d5bf83dd/messages', status: 400, statusText: 'Bad Request', headers: { 'cache-control': 'no-cache, no-store, must-revalidate', connection: 'close', 'content-length': '226', 'content-type': 'application/json', date: 'Thu, 12 May 2022 16:37:03 GMT', 'inin-correlation-id': 'd30fd2ab-80cd-4d31-ab0b-ff695669c665', 'strict-transport-security': 'max-age=600; includeSubDomains', via: '1.1 7285dbd4c05f1133ea7048c8307b03ee.cloudfront.net (CloudFront)', 'x-amz-cf-id': 'PlT9hNxSF3nJWPTwmbDMRmdeJABJzgw5KgmK8BGBU0g2VGzwP-gg==', 'x-amz-cf-pop': 'DUB56-P1', 'x-cache': 'Error from cloudfront' },
Can anyone help with this error?
tim.smith | 2022-05-12 16:48:22 UTC | #2
The response body should contain the error message:
Error code [bad.request] type [ApiErrorException] message [This request requires a user context. Client credentials cannot be used for requests to this resource.] cause type [] cause message []
You can only use this API resource in an application that's used by a human that authorizes with any OAuth flow other than client credentials.
MiquelTrillaRomero | 2022-05-17 15:17:42 UTC | #3
Thank you Tim :+1:!
I've changed to the agentless api but I'm still getting bad request error, can you check with the following correlation-id?
'inin-correlation-id': 'dbeb3a1c-8cae-44a6-a31c-1c9437986300'
Thank you!
Jerome.Saint-Marc | 2022-05-17 15:28:04 UTC | #4
Hello Miquel,
I think it'd be easier if you could post what you set in your request and what you see in your response. An HTTP 400 will contain a body with error/errorMessage.
Most of the people on this forum don't have access to tools to tie the correlation-id back to your request (this is a forum - not the formal Genesys Care support here).
Regards,
MiquelTrillaRomero | 2022-05-17 15:33:29 UTC | #5
Sure Jerome!
This is my request Body (I changed the toAdress for privacy reasons):
body: { "fromAddress": "f809ef8d-a1cd-4130-ae79-eade565ab3cf", "toAddress": "346XXXXXX", "toAddressMessengerType": "whatsapp", "messagingTemplate": { "responseId": "40913bda-98de-40bc-9ac0-de2e01abb4f3", "parameters": [ { "id": "1", "value": "saludo" }, { "id": "2", "value": "nombre" } ] }, "useExistingActiveConversation": true }
This is the response header and body: { type: 'default', url: 'https://api.mypurecloud.ie/api/v2/conversations/messages/agentless', status: 400, statusText: 'Bad Request', headers: { 'cache-control': 'no-cache, no-store, must-revalidate', connection: 'close', 'content-length': '198', 'content-type': 'application/json', date: 'Tue, 17 May 2022 15:26:45 GMT', 'inin-correlation-id': 'e55f6001-0d92-4b7a-ad0a-2dfa00e2e480', 'strict-transport-security': 'max-age=600; includeSubDomains', via: '1.1 e3f435228cbc8657d81bd707948f5910.cloudfront.net (CloudFront)', 'x-amz-cf-id': 'fKkSCKpH-FbGpD--oy-zOqSRpbsRfsGedMW3HuLg7QWR7laM_VWMsw==', 'x-amz-cf-pop': 'DUB56-P1', 'x-cache': 'Error from cloudfront' }, counter: 0, highWaterMark: 16384 }
{ message: 'The request could not be understood by the server due to malformed syntax.', code: 'bad.request', status: 400, contextId: 'e55f6001-0d92-4b7a-ad0a-2dfa00e2e480', details: [], errors: [] }
MiquelTrillaRomero | 2022-05-17 15:46:50 UTC | #6
Guys! you can forget about this, i had to do a JSON.stringify of the body before sending it to serialize it. Once done it worked perfectly!
Thank you any way! hope this helps for others.
system | 2022-06-17 15:47:20 UTC | #7
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: 14723