postMessage API replying with should have required property 'content' when content is in JSON paylod



Data ultimo post: 11 giu 2025

I have a webhook that is subscribed to all message activity. When an end user starts a conversation, I get a post to my webhook at the beginning, and at every subsequent message they type.

 

That all works fine.

 

I want to write a python script that posts back into the conversation after looking up some stuff in my database, doing some calculations, and discovering the answer that the end user needs.

So far, the script extracts the ticket ID from the webhook, and then looks up the conversation ID. That part works.

 

Then when I try to use the postMessage API to put a message back into the conversation, I get a message like this back:

 

{"errors":[{"code":"bad_request","title":"should have required property 'content'"}]}

 

Here is the JSON that contains the content property, just like in the docs example:

$ curl https://api.smooch.io/v2/apps/$ZD_APP_ID/conversations/$CONVERSATION_ID/messages \
  --user $ZD_KEY:$ZD_SECRET \
 -d '{"author": {"type": "business"}, "content": {"type": "text", "text": "Hello!"}}'

Help me obiwan you're my only hope


0

3

3 commenti

      I'm glad that worked, but also a little annoyed, since the error is just straight up wrong. Thankfully I have colleagues around who know things and we need to make sure that the knowledge is in place so that everyone else can have access to it. I'll work with those folks to clean up the error handling, as well as seeing what we can get added to the docs to make this a bit more clear. 

       

      The depths from which your cries have emanated have been heard. :salute:

      1


      Haha that was it!  This is a huge relief.  I would beseech you from the bowels of christ to add this more prominently in the docs.

      Thanks so much for the help!!

      1


      Hey Matt! I was asking a colleague about this, since everything looked correct, and the only thing that they noticed was that the content-header was missing. No idea if this will resolve it…and if it does, we need to clean up that error handling…but could you give this a shot and let me know your results? For reference, we do technically mention that here, but I also missed it, so no judgment!

      curl https://api.smooch.io/v2/apps/$ZD_APP_ID/conversations/$CONVERSATION_ID/messages \
       --user $ZD_KEY:$ZD_SECRET \
       -H "content-Type: application/json" \
       -d '{"author": {"type": "business"}, "content": {"type": "text", "text": "Hello!"}}'

      1


      Accedi per lasciare un commento.

      Non hai trovato quello che cerchi?

      Nuovo post