You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Logic App向Microsoft Graph发送HTTP POST请求无法携带Id问题

解决Logic App中无法从解析的JSON提取Id到Graph POST请求体的问题

问题背景

在Logic App中向Microsoft Graph发送HTTP POST请求时,已完成JSON解析操作,但无法将提取到的Id带入请求体,导致请求异常。

相关截图

JSON解析步骤配置
解析后的字段预览
HTTP POST请求输入配置
Graph API版本设置

解析的JSON结构

{
    "properties": {
        "body": {
            "properties": {
                "@@odata.context": {
                    "type": "string"
                },
                "businessPhones": {
                    "type": "array"
                },
                "displayName": {
                    "type": "string"
                },
                "givenName": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "jobTitle": {
                    "type": "string"
                },
                "mail": {
                    "type": "string"
                },
                "mobilePhone": {},
                "officeLocation": {
                    "type": "string"
                },
                "preferredLanguage": {},
                "surname": {
                    "type": "string"
                },
                "userPrincipalName": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "headers": {
            "properties": {
                "Cache-Control": {
                    "type": "string"
                },
                "Content-Type": {
                    "type": "string"
                },
                "Date": {
                    "type": "string"
                },
                "OData-Version": {
                    "type": "string"
                },
                "Strict-Transport-Security": {
                    "type": "string"
                },
                "Transfer-Encoding": {
                    "type": "string"
                },
                "Vary": {
                    "type": "string"
                },
                "client-request-id": {
                    "type": "string"
                },
                "request-id": {
                    "type": "string"
                },
                "x-ms-ags-diagnostic": {
                    "type": "string"
                },
                "x-ms-resource-unit": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "statusCode": {
            "type": "integer"
        }
    },
    "type": "object"
}

解决方案

1. 修正Id的引用路径

根据解析后的JSON结构,Id的正确嵌套路径是body.id,在Logic App中需结合解析步骤的名称编写表达式:

  • 假设你的JSON解析步骤名称为解析JSON,则正确的表达式为:
    @{body('解析_JSON')?['body']?['id']}
    
  • 直接在HTTP POST请求体的对应位置替换成该表达式,确保路径层级正确,避免遗漏外层body节点。

2. 验证解析步骤的实际输出

  • 进入Logic App的运行历史,找到对应的运行实例,查看“解析JSON”步骤的输出内容,确认id字段存在且有有效值,排除原响应中Id为空的情况。

3. 检查Graph请求的格式要求

  • 若调用的是添加用户到组这类特定Graph API,请求体中的Id字段需符合Graph规范,例如:
    {
      "@odata.id": "https://graph.microsoft.com/v1.0/users/@{body('解析_JSON')?['body']?['id']}"
    }
    
  • 确保HTTP请求的Content-Type头部设置为application/json,避免格式不匹配导致参数丢失。

4. 测试表达式有效性

  • 在Logic App的表达式编辑器中输入上述Id引用表达式,查看右侧预览值是否正确显示用户Id,确认表达式无语法错误。

内容的提问来源于stack exchange,提问作者user22314971

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 10:57:31