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

如何在Logic Apps中获取HTTP响应的access_token值

如何正确获取HTTP响应中的access_token值?

我需要从HTTP响应中提取access_token值,该响应的结构如下:

"body": {
    "token_type": "string",
    "expires_in": "number but as string",
    "ext_expires_in": "same",
    "expires_on": "same",
    "not_before": "number but as string",
    "resource": "string",
    "access_token": "string"
}

我在「设置变量」操作中使用了表达式 body('parse_JSON')?[variables('access_token')],结果触发了以下错误:

InvalidTemplate. Unable to process template language expressions in action 'Set_Access_Token' inputs at line '0' and column '0': 'The template language expression 'body('Parse_JSON')?[triggerBody()?['access_token']]' cannot be evaluated because property '' cannot be selected. 请查看逻辑表达式相关文档了解详情.'

我的工作流结构如下:
工作流结构

正确的提取方式

  • 若已通过「Parse JSON」操作完成响应解析,直接通过以下两种方式访问access_token属性即可:
    1. 方括号写法:
      body('Parse_JSON')?['access_token']
      
    2. 点符号写法:
      body('Parse_JSON')?.access_token
      
  • 你之前的错误原因是误用了variables('access_token'),如果该变量未定义或值为空,会导致尝试访问空属性名,进而触发错误。直接使用字符串字面量'access_token'或点符号访问目标属性即可解决问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 03:24:37