Azure 逻辑应用程序无法从解析JSON操作中找到值
我有一个由HTTP调用触发的逻辑应用程序。随着这个调用而来的是一组头,其中大多数用于不同的switch语句。使用我从请求中输入的Parse JSON操作,它们成功地解析了头(图1),但是对于其中一个头(searchType),switch语句由于某种原因计算为null(图2)。 我一辈子都不知道为什么 我尝试从头开始重新制作logic应用程序,将应用程序完全复制到不同的环境中,并尝试使用表达式来访问解析的值,而不是动态内容。当我尝试这个表达式时,我被告知它是一个无效的表达式(图3)。此表达式是代码视图中使用的表达式的直接副本 我能做些什么来解决这个问题,有什么建议吗 复制逻辑应用程序的JSONAzure 逻辑应用程序无法从解析JSON操作中找到值,azure,azure-logic-apps,Azure,Azure Logic Apps,我有一个由HTTP调用触发的逻辑应用程序。随着这个调用而来的是一组头,其中大多数用于不同的switch语句。使用我从请求中输入的Parse JSON操作,它们成功地解析了头(图1),但是对于其中一个头(searchType),switch语句由于某种原因计算为null(图2)。 我一辈子都不知道为什么 我尝试从头开始重新制作logic应用程序,将应用程序完全复制到不同的环境中,并尝试使用表达式来访问解析的值,而不是动态内容。当我尝试这个表达式时,我被告知它是一个无效的表达式(图3)。此表达式是代
{
"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
为空,可能是ParseJson
模式不正确,因此请确保正确的模式作为默认模式
如果您想使用头数据,您不需要将头解析为json,因为数据已经是json格式,但是如果您通过请求体传递数据,则需要对其进行解析。我还测试了它,它将与triggerOutputs()['headers']['searchType']一起工作,所以只要将它粘贴到表达式中,如果使用代码视图,它将是@triggerOutputs()['headers']['searchType']
表达式无效是因为表达式中的
@
表达式在代码视图中使用@
表达式,它应该是body('HeadersJson')?['searchType']
至于您的searchType
为空,可能是ParseJson
模式不正确,因此请确保正确的模式作为默认模式
如果您想使用头数据,您不需要将头解析为json,因为数据已经是json格式,但是如果您通过请求体传递数据,则需要对其进行解析。我还测试了它,它将与triggerOutputs()['headers']['searchType']一起工作,所以只要将它粘贴到表达式中,如果使用代码视图,它将是@triggerOutputs()['headers']['searchType']