Building an Android app with the Kotlin SDK for Web Messaging. We need to set a specific wrap-up code once the session closes, but ConversationApi doesn’t expose a direct updateWrapUp method for ended conversations. Trying to POST to /api/v2/conversations/webmessaging/{conversationId}/wrapup with wrapUpCodeId returns 405 Method Not Allowed. Is there a supported way to trigger this via the SDK or REST API after the onConversationEnded callback fires?
{ "wrapUpCodeId": "abc-123" }
The 405 error usually means the conversation state is already locked or the endpoint expects a different payload structure for post-call actions. You can’t just patch the wrap-up code directly on an ended conversation via the standard update method. Try using the wrapup resource specifically, but ensure the conversation is in a WRAPPED_UP or CLOSED state first. If it’s fully closed, you might need to use the analytics API to tag it, but for active routing, stick to the wrap-up endpoint before closure. Here’s a curl example that works for the REST API, which you can mirror in Kotlin with OkHttp:
curl -X POST "https://api.mypurecloud.com/api/v2/conversations/webmessaging/{conversationId}/wrapup" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"wrapUpCodeId": "your-wrap-up-code-id"
}'
Make sure your OAuth token includes the conversation:wrapup:update scope, or it’ll silently fail with a 401. The SDK might be caching an older client version that doesn’t support this POST correctly. Check your genesys-cloud-sdk version.