What is the correct Command message response?

I implemented a entry point for command received by synapse. I get called but something goes wrong with the command message response. Here have this error:

org.http4s.InvalidMessageBodyFailure: Invalid message body: Could not decode 
JSON: <REDACTED>

with this message response:

{
"id": "59eed54e-ccb4-48ac-af01-144f0ca68f67",
"payload": {
"some": "payload"
},
"payloadType": "local.application.client.Payload",
"payloadRevision": "1"
}

or this error:

org.http4s.client.UnexpectedStatus: unexpected HTTP status: 500 Internal Server Error for request POST http://localhost:8080/v1/contexts/default/commands

with this response

{
"id": "59eed54e-ccb4-48ac-af01-144f0ca68f67",
"payload": {
"some": "payload"
}
}

The second response is probably incomplete but what’s wrong with my first response ?

Hi Dominique,

If I understand correctly, you’ve set up a command handler in Synapse that points to your application. When you send a command, and it’s dispatched to your application, you get the error:

org.http4s.InvalidMessageBodyFailure: Invalid message body: Could not decode 
JSON: <REDACTED>

What’s your command handler configuration? Does it use http-raw or http-message endpoint type? Could you check the received headers, specifically the Content-Type? Does the library try to parse the body to a generic JSON object or a model generated from the schema?

The next error seems to be related to sending a command:

org.http4s.client.UnexpectedStatus: unexpected HTTP status: 500 Internal Server Error for request POST http://localhost:8080/v1/contexts/default/commands

Could you check what Synapse logs about this 500 error? From the URL, I see it’s a http-message-based endpoint. It expects the following body format:

{
  "id": "59eed54e-ccb4-48ac-af01-144f0ca68f67",
  "metaData": {
    "some key": "some value",
    "another key": "another value"
  },
  "payload": {
    "some": "payload"
  },
  "payloadType": "local.application.client.Payload",
  "payloadRevision": "1",
  "name": "local.application.client.Command",
  "routingKey": "fa797f82-24e8-459f-9d30-b004af411c13",
  "priority": 100
}

The name property is required, but I don’t see it in your request. It’s necessary to route commands to appropriate handlers. You can check the schema at Axon Synapse API.
Alternatively, you can try the variation of this endpoint that takes the command name in the path and treats the entire body as a payload - Axon Synapse API.

Regards,
Michal