如何在 Azure 逻辑应用程序中使用 Compose 操作更改 JSON 结构?
How to use change JSON structure using Compose action in Azure Logic Apps?
我正在尝试更改 JSON 从我使用 Logic 应用发出的请求中得到的响应:
此请求将得到以下响应:
{
"invoiceID":1,
"formType":"invoice",
"amount":449,
"currency":"eur",
"description":"Invoice real estate",
"period":{"end":20122019,"start":20122020},
"owner":{
"id":91434,
"firstname":"John",
"lastname":"Doe",
"dateOfBirth":1121993,
"phoneNumber":345435435,
"countryOfBirth":"Nederland",
"IBAN":"NL28 ABNA 743734g763474324"
},
"property":{
"id":105,
"type":"apartment",
"address":"ghost lane 13",
"ZIP":"7888 CK",
"State\/Province":"Groningen",
"country":"Nederland",
"construction-year":15072009,
"previousOwners":9
},
"previousProperties":[54,193,11,454,18]
}
现在我正在尝试将上面的 JSON 组合成另一个 json 结构,例如:
{
"general": {
"invoiceID": 12,
"formType": "invoice",
"amount": 449,
"currency": "eur",
"description": "Invoice real estate",
"period": {
"end": 20122019,
"start": 20122020
}
}
}
我尝试为此使用撰写操作:
最后我return回复:
]]
此设置不起作用,我收到以下错误:
{"error":{"code":"NoResponse","message":"服务器没有收到上游服务器的应答。请求中的trace-id是08586376520125765844944852801CU36 ”}}
当我从逻辑应用程序设计器中删除撰写操作时,流程确实有效,但我得到的是原始 JSON 响应。
更新
我的撰写配置有以下选项:
从你的图片来看,你的响应主体设置了 HTTP 操作主体,你需要设置 Compose
输出,下面是我的测试结果,我没有得到你的错误。也许你可以看看。看起来在您的撰写操作中,您将值设置为错误的值,根据您的要求,您需要使用 HTTP
获取操作输出来设置它们。
我使用 HTTP 触发器进行测试。
下面是我的撰写输入:
"general": {
"amount": "@body('HTTP')['amount']",
"currency": "@body('HTTP')['currency']",
"description": "@body('HTTP')['description']",
"formType": "@body('HTTP')['formType']",
"invoiceID": "@body('HTTP')['invoiceID']",
"period": {
"end": "@body('HTTP')['period']['end']",
"start": "@body('HTTP')['period']['start']"
}
}
这是我的邮递员得到的回复。
希望对您有所帮助。
我正在尝试更改 JSON 从我使用 Logic 应用发出的请求中得到的响应:
此请求将得到以下响应:
{
"invoiceID":1,
"formType":"invoice",
"amount":449,
"currency":"eur",
"description":"Invoice real estate",
"period":{"end":20122019,"start":20122020},
"owner":{
"id":91434,
"firstname":"John",
"lastname":"Doe",
"dateOfBirth":1121993,
"phoneNumber":345435435,
"countryOfBirth":"Nederland",
"IBAN":"NL28 ABNA 743734g763474324"
},
"property":{
"id":105,
"type":"apartment",
"address":"ghost lane 13",
"ZIP":"7888 CK",
"State\/Province":"Groningen",
"country":"Nederland",
"construction-year":15072009,
"previousOwners":9
},
"previousProperties":[54,193,11,454,18]
}
现在我正在尝试将上面的 JSON 组合成另一个 json 结构,例如:
{
"general": {
"invoiceID": 12,
"formType": "invoice",
"amount": 449,
"currency": "eur",
"description": "Invoice real estate",
"period": {
"end": 20122019,
"start": 20122020
}
}
}
我尝试为此使用撰写操作:
最后我return回复:
此设置不起作用,我收到以下错误:
{"error":{"code":"NoResponse","message":"服务器没有收到上游服务器的应答。请求中的trace-id是08586376520125765844944852801CU36 ”}}
当我从逻辑应用程序设计器中删除撰写操作时,流程确实有效,但我得到的是原始 JSON 响应。
更新
我的撰写配置有以下选项:
从你的图片来看,你的响应主体设置了 HTTP 操作主体,你需要设置 Compose
输出,下面是我的测试结果,我没有得到你的错误。也许你可以看看。看起来在您的撰写操作中,您将值设置为错误的值,根据您的要求,您需要使用 HTTP
获取操作输出来设置它们。
我使用 HTTP 触发器进行测试。
下面是我的撰写输入:
"general": {
"amount": "@body('HTTP')['amount']",
"currency": "@body('HTTP')['currency']",
"description": "@body('HTTP')['description']",
"formType": "@body('HTTP')['formType']",
"invoiceID": "@body('HTTP')['invoiceID']",
"period": {
"end": "@body('HTTP')['period']['end']",
"start": "@body('HTTP')['period']['start']"
}
}
这是我的邮递员得到的回复。
希望对您有所帮助。