逻辑应用无法从 Parse JSON 操作中找到值
Logic app fails to find value from Parse JSON action
我有一个由 HTTP 调用触发的逻辑应用程序。此调用附带一组 headers,其中大部分用于不同的 switch 语句。使用我从请求中输入 headers 的 Parse JSON 操作,它们成功解析(图 1),但是对于 headers(searchType)之一,switch 语句的计算结果为 null某些原因(图 2)。
我一辈子都弄不明白为什么。
我尝试从头开始重新制作逻辑应用程序,将应用程序完全复制到不同的环境,并尝试使用表达式访问解析值而不是动态内容。当我尝试表达式时,我被告知它是一个无效的表达式(图 3)。此表达式是代码视图中使用的内容的直接副本。
关于我可以做些什么来解决这个问题有什么建议吗?
Successful parsing of headers
parsed header evaluates to null
expression invalid
JSON 复制逻辑应用
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"HeadersJson": {
"inputs": {
"content": "@triggerOutputs()['headers']",
"schema": {
"properties": {
"APICallFor": {
"type": "string"
},
"Accept-Encoding": {
"type": "string"
},
"Accept-Language": {
"type": "string"
},
"Connection": {
"type": "string"
},
"Content-Length": {
"type": "string"
},
"Content-Type": {
"type": "string"
},
"Host": {
"type": "string"
},
"User-Agent": {
"type": "string"
},
"searchType": {
"type": "string"
},
"x-ms-action-tracking-id": {
"type": "string"
},
"x-ms-activity-vector": {
"type": "string"
},
"x-ms-client-request-id": {
"type": "string"
},
"x-ms-client-tracking-id": {
"type": "string"
},
"x-ms-correlation-id": {
"type": "string"
},
"x-ms-execution-location": {
"type": "string"
},
"x-ms-tracking-id": {
"type": "string"
},
"x-ms-workflow-id": {
"type": "string"
},
"x-ms-workflow-name": {
"type": "string"
},
"x-ms-workflow-operation-name": {
"type": "string"
},
"x-ms-workflow-resourcegroup-name": {
"type": "string"
},
"x-ms-workflow-run-id": {
"type": "string"
},
"x-ms-workflow-run-tracking-id": {
"type": "string"
},
"x-ms-workflow-subscription-id": {
"type": "string"
},
"x-ms-workflow-system-id": {
"type": "string"
},
"x-ms-workflow-version": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
},
"Switch": {
"cases": {
"Get_Departments": {
"actions": {
"Switch_3": {
"cases": {
"Case": {
"actions": {
"Response_5": {
"inputs": {
"body": "got to individual",
"statusCode": 200
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
},
"case": "individual"
},
"Case_2": {
"actions": {
"Response": {
"inputs": {
"body": "got to bulk",
"statusCode": 200
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
},
"case": "bulk"
}
},
"default": {
"actions": {
"Response_3": {
"inputs": {
"body": "the searchType parameter is not valid",
"statusCode": 200
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
}
},
"expression": "@body('HeadersJson')?['serachType']",
"runAfter": {},
"type": "Switch"
}
},
"case": "departments"
}
},
"default": {
"actions": {
"Response_2": {
"inputs": {
"body": "the APICallFor header is not valid",
"statusCode": 500
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
}
},
"expression": "@body('HeadersJson')?['APICallFor']",
"runAfter": {
"HeadersJson": [
"Succeeded"
]
},
"type": "Switch"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"searchString": {
"type": "string"
},
"searchType": {
"type": "string"
}
},
"type": "object"
}
},
"kind": "Http",
"operationOptions": "EnableSchemaValidation",
"type": "Request"
}
}
}
}
你的表达式无效是因为你的表达式中的@
,代码视图中使用了@
表达式,它应该只是body('HeadersJson')?['searchType']
.
至于你的searchType
为null,可能是ParseJson
schema不正确,所以请确保正确的schema如doc way.
如果你想使用头数据,你不需要将头解析为json,因为数据已经是json格式,但是如果你通过请求传递数据body 你需要解析它。我也测试过它,它可以与 triggerOutputs()['headers']['searchType']
一起使用,所以只需将它粘贴到表达式中,如果您使用代码视图,它将是 @triggerOutputs()['headers']['searchType']
.
我有一个由 HTTP 调用触发的逻辑应用程序。此调用附带一组 headers,其中大部分用于不同的 switch 语句。使用我从请求中输入 headers 的 Parse JSON 操作,它们成功解析(图 1),但是对于 headers(searchType)之一,switch 语句的计算结果为 null某些原因(图 2)。 我一辈子都弄不明白为什么。
我尝试从头开始重新制作逻辑应用程序,将应用程序完全复制到不同的环境,并尝试使用表达式访问解析值而不是动态内容。当我尝试表达式时,我被告知它是一个无效的表达式(图 3)。此表达式是代码视图中使用的内容的直接副本。
关于我可以做些什么来解决这个问题有什么建议吗?
Successful parsing of headers
parsed header evaluates to null
expression invalid
JSON 复制逻辑应用
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"HeadersJson": {
"inputs": {
"content": "@triggerOutputs()['headers']",
"schema": {
"properties": {
"APICallFor": {
"type": "string"
},
"Accept-Encoding": {
"type": "string"
},
"Accept-Language": {
"type": "string"
},
"Connection": {
"type": "string"
},
"Content-Length": {
"type": "string"
},
"Content-Type": {
"type": "string"
},
"Host": {
"type": "string"
},
"User-Agent": {
"type": "string"
},
"searchType": {
"type": "string"
},
"x-ms-action-tracking-id": {
"type": "string"
},
"x-ms-activity-vector": {
"type": "string"
},
"x-ms-client-request-id": {
"type": "string"
},
"x-ms-client-tracking-id": {
"type": "string"
},
"x-ms-correlation-id": {
"type": "string"
},
"x-ms-execution-location": {
"type": "string"
},
"x-ms-tracking-id": {
"type": "string"
},
"x-ms-workflow-id": {
"type": "string"
},
"x-ms-workflow-name": {
"type": "string"
},
"x-ms-workflow-operation-name": {
"type": "string"
},
"x-ms-workflow-resourcegroup-name": {
"type": "string"
},
"x-ms-workflow-run-id": {
"type": "string"
},
"x-ms-workflow-run-tracking-id": {
"type": "string"
},
"x-ms-workflow-subscription-id": {
"type": "string"
},
"x-ms-workflow-system-id": {
"type": "string"
},
"x-ms-workflow-version": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
},
"Switch": {
"cases": {
"Get_Departments": {
"actions": {
"Switch_3": {
"cases": {
"Case": {
"actions": {
"Response_5": {
"inputs": {
"body": "got to individual",
"statusCode": 200
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
},
"case": "individual"
},
"Case_2": {
"actions": {
"Response": {
"inputs": {
"body": "got to bulk",
"statusCode": 200
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
},
"case": "bulk"
}
},
"default": {
"actions": {
"Response_3": {
"inputs": {
"body": "the searchType parameter is not valid",
"statusCode": 200
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
}
},
"expression": "@body('HeadersJson')?['serachType']",
"runAfter": {},
"type": "Switch"
}
},
"case": "departments"
}
},
"default": {
"actions": {
"Response_2": {
"inputs": {
"body": "the APICallFor header is not valid",
"statusCode": 500
},
"kind": "Http",
"runAfter": {},
"type": "Response"
}
}
},
"expression": "@body('HeadersJson')?['APICallFor']",
"runAfter": {
"HeadersJson": [
"Succeeded"
]
},
"type": "Switch"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"searchString": {
"type": "string"
},
"searchType": {
"type": "string"
}
},
"type": "object"
}
},
"kind": "Http",
"operationOptions": "EnableSchemaValidation",
"type": "Request"
}
}
}
}
你的表达式无效是因为你的表达式中的@
,代码视图中使用了@
表达式,它应该只是body('HeadersJson')?['searchType']
.
至于你的searchType
为null,可能是ParseJson
schema不正确,所以请确保正确的schema如doc way.
如果你想使用头数据,你不需要将头解析为json,因为数据已经是json格式,但是如果你通过请求传递数据body 你需要解析它。我也测试过它,它可以与 triggerOutputs()['headers']['searchType']
一起使用,所以只需将它粘贴到表达式中,如果您使用代码视图,它将是 @triggerOutputs()['headers']['searchType']
.