3

I am designing an IVR with Twilio studio, so it remains modular and flexible. At some point I have to use the widget "http request" to an external application. When I complete the widget, if I select content type "Application/JSON" instead of "Form URL Encoded" (this is needed by my external application), then the field of the hearders dissapears and it is not possible annymore to specify a Authorization/Bearer like a normal POST request. If I switch back to "From URL encoded", then the field appears again.

Is this a bug ? is this a feature ? do I do something wrong ?

I have been through all the doc I found (Twilio, stack overflow; google), and I tried to switch from Chrome and Firefox, but it remains the same.

Anybody an idea please ?

NB I think I can solve this by creating a backend app like a Twilio function that can be called by a post without authorization bearer and it will do the POST of my JSON to the external app (with authorization and bearer, hardcoded inside the function). But then I could better stop using twilio studio and code everything in the function ... what I wanted to avoid. Thx in advance

1 Answers1

6

Twilio developer evangelist here.

The parameters that you can add to the HTTP request widget are body parameters, not headers. So you can't achieve this with either style of HTTP request.

Instead, I would recommend using the Twilio Function widget to make the request to your external application. You don't need to use an HTTP widget in the middle there, you can do it straight in the Function. The Function can then handle your custom HTTP request and pass the details back to the Studio flow as long as it responds with JSON.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • 1
    Thank you for clarification and confirmation. I will use a Twilio function as you suggest. – Laurent Berti Dec 05 '18 at 07:13
  • Hi, do you know of any examples of how to make this work. Please see my question that shows the .Net code I am trying to emulate with Studio. https://stackoverflow.com/questions/57113249/twilio-studio-http-post-request-header/57113919#57113919 – Joe C Jul 19 '19 at 13:54
  • @JoeC as I suggest, Studio can’t do this, so use a Twilio Function to run some Node.js to run the request for you and pass off to it using the Function widget. Or, host your own .NET server and use the code you wrote to make it work and call that with the HTTP request widget. – philnash Jul 19 '19 at 23:07
  • Thank you for answering. I was able to accomplish this using a function with got. – Joe C Jul 23 '19 at 16:36