Azure 逻辑应用程序 http 连接器不解析查询中的 json
Azure logic apps http connector does not parse json in queries
{
"Query": {
"inputs": {
"headers": {
"Content-Type": "application/json"
},
"method": "GET",
"queries": {
"f": "json",
"temp": "\"test\": @json(body('http'))['candidates'][0]['location']['x']"
},
"uri": "https://testurl.com/restApi"
},
"runAfter": {
},
"type": "Http"
}
}
它将 "temp" 读作 "test" :@json(body('http'))['candidates'][0]['location']['x']"
如果我将此行更改为
"temp": "@json(body('http'))['candidates'][0]['location']['x']"
它从 json 中读取了正确的值。不确定这是一个错误,还是我遗漏了一些语法。
你能试试下面的语法吗:
"temp": "\"test\": @{json(body('http'))['candidates'][0]['location']['x']}"
您可以试试 Steven 回答的内容 () 或这个对我来说更明确的答案:
"temp": "@concat('\"test\":', json(body('http'))['candidates'][0]['location']['x'])"
我建议您在此处阅读工作流定义语言中的字符串插值:https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#Expressions
你的情况似乎是一个极限情况。你要么以 @
或 @{
开始你的表达式,然后是你的函数的名称,要么你可以以一个字符串开始,但你别无选择,只能使用 @{
{
"Query": {
"inputs": {
"headers": {
"Content-Type": "application/json"
},
"method": "GET",
"queries": {
"f": "json",
"temp": "\"test\": @json(body('http'))['candidates'][0]['location']['x']"
},
"uri": "https://testurl.com/restApi"
},
"runAfter": {
},
"type": "Http"
}
}
它将 "temp" 读作 "test" :@json(body('http'))['candidates'][0]['location']['x']"
如果我将此行更改为
"temp": "@json(body('http'))['candidates'][0]['location']['x']"
它从 json 中读取了正确的值。不确定这是一个错误,还是我遗漏了一些语法。
你能试试下面的语法吗:
"temp": "\"test\": @{json(body('http'))['candidates'][0]['location']['x']}"
您可以试试 Steven 回答的内容 (
"temp": "@concat('\"test\":', json(body('http'))['candidates'][0]['location']['x'])"
我建议您在此处阅读工作流定义语言中的字符串插值:https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#Expressions
你的情况似乎是一个极限情况。你要么以 @
或 @{
开始你的表达式,然后是你的函数的名称,要么你可以以一个字符串开始,但你别无选择,只能使用 @{