Modifying Xano API response Content-Type to "text/xml"

Options

Hello - I have connected my Xano API to Twilio. When my Twilio number receives a text, the information is forwarded to my API via webhook. This is all working well.

Unfortunately, Twilio requires an empty Response element in text/xml format. Without this response, I am receiving errors.

Would someone please let me know the best way to modify the Xano API response Content-Type from json to xml?

For further context, the objective I'm trying to solve for is summed up well by lucky.expert's comment on Stack Overflow: https://stackoverflow.com/questions/41646394/twilio-error-12300-invalid-content-type-only-sometimes

Thanks in advance for any help.

Tagged:

Answers

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    Under utility in the functions menu there is one to create a custom header. You can use that to set "Content-Type: text/xml"

  • WMcCartney
    WMcCartney Member
    Options

    Thanks again for your help @Ray Deck.

    I added the custom header to my workflow (Content-Type: text/xml). Unfortunately, I am still receiving the "Invalid Content-Type" error from Twilio.

    When I check Xano, it shows the response to include "Content-Type: application/json" and not the new custom header "Content-Type: text/xml"

    Here is my function stack:

    And here is the expanded response:

    Thanks again for your help.

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    OK, that response looks weird in the screenshot. Can you open it up, and make the response jsut blank, and return as "self". That will make the end point be "NA" as "self" and maybe we get a different result

  • WMcCartney
    WMcCartney Member
    Options

    Sure thing - here is the new endpoint:

    Xano response:

    Unfortunately, same error in Twilio:

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    So I tried putting the folloiwng into the response:

    <Response></Response>
    

    When I did, the header took. Otherwise, I think Xano or its Nginx proxy are detecting a non-xml response and replacing the output.

    Which webhook type are you using that requires a blank body (as opposed to a blank Twiml response, which is what I put into the code block above)

  • WMcCartney
    WMcCartney Member
    Options

    Awesome, thanks @Ray Deck. I added the response and the new Content-Type worked. Also, I have stopped receiving the Twilio errors. Thanks a lot.