简体   繁体   中英

How to use SAS token Url in HTTP as Status callback - PowerAutomate

I am using PowerAutomate to make a call to Twilio. I use "StatusCallback" and in that I use a URL to another PowerAutomate (Trigger HTTP Request is received) URl. This Url contains the SAS token in the Url.

Sample Payload parameters

Body: Hi from post!!!
To: +1425******2
From: +1623******4
StatusCallback: https://prod-21.uksouth.logic.azure.com:443/workflows/53edd52****42***432424*****ed48839/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=YP7zZTf*****_H26hZT********8Ytfd*****8

The Status callback never gets called. In the Twilio account I can see the error because the Url gets truncated.

I understand why this is getting done, but what i want to know is how to resolve this issue.

Adding a failure that i see on Twilio. It is clearly that the Url Twilio is trying is truncated. 在此处输入图像描述

Twilio is actually not displaying your full URL in the log there, but I believe it is making the full request. The issue is not the query parameters in the URL, but the format of the request. You can see in the request inspector the body of the response has an error message:

The input body for trigger 'manual' of type 'Request' must be of type JSON, but was of type 'application/x-www-form-urlencoded; charset=utf-8'.

Your PowerAutomate HTTP trigger expects the HTTP request to be made to be of type JSON, but Twilio webhooks make HTTP requests in the format application/x-www-form-urlencoded .

I am finding it difficult to find the documentation on HTTP triggers in PowerAutomate, but if it is possible to change, I would recommend changing the format that the trigger will receive to application/x-www-form-urlencoded .

If that is not possible, then you will need to translate the original Twilio request into JSON format before sending it to your trigger. You could achieve this with a Twilio Function . Something like this could work:

const axios = require('axios');

exports.handler = async (context, event, callback) => {
  const data = { ...event };
  data.request = undefined;

  await axios.post(context.URL, data) 

  callback(null, new Twilio.twiml.MessagingResponse());
}

This would take all the data sent in to the webhook, turn it into JSON data and POST it to your trigger (saved as an environment variable called URL in this case). There is more on how to write Twilio Functions here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM