Trying to implement a custom client for Genesys Cloud messaging without using the widget. The goal is to send messages directly via the Guest API using a Node.js script. I have a valid access token and an existing conversation ID from a previous session.
Here is the request setup:
const response = await fetch('https://api.mypurecloud.com/api/v2/conversations/messaging/messages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
conversationId: 'existing-conversation-id-here',
text: 'Test message from custom client'
})
});
The response is consistently a 400 Bad Request. The error payload says “Invalid request body” but the structure matches the docs. I’ve verified the conversation ID is active and the token has the required scopes. No other errors in the logs. What am I missing in the payload structure?