我有一个逻辑应用,该应用由HTTP调用触发。伴随此调用的是一组标头,其中大多数标头用于不同的switch语句中。通过使用解析JSON操作,我从请求中输入了标头,它们成功地进行了解析(图像1),但是对于其中一个标头(searchType),switch语句由于某种原因而评估为null(图像2)。 我无法为自己的生活弄清楚原因。
我试图从头开始重新制作逻辑应用程序,将其完全复制到另一个环境,并尝试使用表达式访问解析后的值,而不是动态内容。当我尝试该表达式时,会被告知它是无效的表达式(图3)。该表达式是代码视图中使用的表达式的直接副本。
关于我该如何解决这个问题的任何建议?
parsed header evaluates to null
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"
}
}
}
}
答案 0 :(得分:1)
您的表达式无效是因为您的表达式中的this.Subscription = combineLatest([a,b])
.pipe(
map( (...) )
).subscribe( (...) );
(在代码视图中使用了@
表达式,它应该只是@
。
关于您的body('HeadersJson')?['searchType']
为空,可能是searchType
模式不正确,因此请确保正确的模式为doc way。
如果要使用标头数据,则不需要将标头解析为json,因为数据已经是json格式,但是如果将数据传递给请求主体,则需要对其进行解析。我也已经对其进行了测试,它将与ParseJson
一起使用,因此只需将其粘贴到表达式中,如果使用代码视图,它将为triggerOutputs()['headers']['searchType']
。