Guest API message send returns 400 Bad Request in C#

  • .NET 8
  • Genesys Cloud .NET SDK v5
  • Azure Function

My config is not working… I am trying to send a message via the Guest API without the widget. The docs state: “POST /api/v2/webmessaging/guest/messages”. My code uses the standard HttpClient pattern.

var response = await client.PostAsJsonAsync(url, payload);

I get a 400 error. The JSON payload looks correct. What is the correct structure for the guest message body in C#?

Pretty sure the Content-Type header must be application/json and the payload requires a guestId string. In Go, I’d verify the struct tags map correctly to avoid serialization issues.

It’s worth reviewing at the SDK usage for cleaner code.

  • use platformClient.Conversations.Messages.PostWebmessagingGuestMessages instead of raw HttpClient.
  • ensure your payload includes guestId and to (the endpoint ID).
  • verify the Content-Type header is explicitly set to application/json in the SDK client config.