[英]Azure Logic App: how to make a x-www-form-encoded?
I'm trying to make a request with Content-Type x-www-form-urlencoded that works perfectly in postman but does not work in Azure Logic App I receive a Bad Request response for missing parameters, like I'd not send enything.我正在尝试使用Content-Type x-www-form-urlencoded发出请求,它在 postman 中完美运行,但在 Azure 逻辑应用程序中不起作用我收到一个错误的请求响应,因为缺少参数,就像我没有发送任何东西一样。
I'm using the Http action.我正在使用 Http 操作。
The body value is param1=value1¶m2=value2, but I tried other formats. body值是param1=value1¶m2=value2,但我试过其他格式。
Answering this one, as I needed to make a call like this myself, today.接听这个,因为我今天需要自己拨打这样的电话。 As Assaf mentions above, the request indeed has to be urlEncoded and a lot of times you want to compose the actual message payload.
正如 Assaf 上面提到的,请求确实必须是 urlEncoded 并且很多时候您想要编写实际的消息有效负载。
Also, make sure to add the Content-Type
header in the HTTP action with value application/x-www-form-urlencoded
另外,请确保在 HTTP 操作中添加
Content-Type
标头,其值为application/x-www-form-urlencoded
therefore, you can use the following code to combine variables that get urlEncoded:因此,您可以使用以下代码来组合获取 urlEncoded 的变量:
concat('token=', **encodeUriComponent**(body('ApplicationToken')?['value']),'&user=', **encodeUriComponent**(body('UserToken')?['value']),'&title=Stock+Order+Status+Changed&message=to+do')
When using the concat function (in composing), the curly braces are not needed.使用 concat 函数(在组合中)时,不需要花括号。
Try out the below solution . Its working for me .
concat(
'grant_type=',encodeUriComponent('authorization_code'),
'&client_id=',encodeUriComponent('xxx'),
'&client_secret=',encodeUriComponent('xxx'),
'&redirect_uri=',encodeUriComponent('xxx'),
'&scope=',encodeUriComponent('xxx'),
'&code=',encodeUriComponent(triggerOutputs()['relativePathParameters']['code'])).
Here code is dynamic parameter coming from the previous flow's query parameter.
NOTE : **Do not forget to specify in header as Content-Type ->>>> application/x-www-form-urlencoded**
First of all the body needs to be:首先身体需要:
{ param1=value1¶m2=value2 }
(ie surround with {}) (即用 {} 包围)
That said, value1 and value2 should be url encoded.也就是说, value1 和 value2 应该是 url 编码的。 If they are a simple string (e..g a_b) then this would be find as is but if it is for exmaple https://ab it should be converted to https%3A%2F%2Fa.b
如果它们是一个简单的字符串(例如 a_b),则可以按原样查找,但如果是例如https://ab ,则应将其转换为 https%3A%2F%2Fa.b
The easiest way I found to do this is to use https://www.urlencoder.org/ to convert it.我发现最简单的方法是使用https://www.urlencoder.org/来转换它。 convert each param separately and put the converted value instead of the original one.
分别转换每个参数并放置转换后的值而不是原始值。
HTTP Method: POST
URI : https://xxx/oauth2/token
In Headers section, add the below content-type:在标题部分,添加以下内容类型:
Content-Type: application/x-www-form-urlencoded
And in the Body, add:在正文中,添加:
grant_type=xxx&client_id=xxx&resource=xxx&client_secret=xxx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.