VSCODE REST客户端扩展名 - 从属性响应器JSON复杂对象中获取值

发布于 2025-01-19 22:28:46 字数 833 浏览 2 评论 0原文

使用 Visual Studio Code 和 Rest 客户端扩展: 我正在调用返回 JSON 对象的端点。我试图获取该对象的“AccessToken”属性,但它不返回值。 可能做错了什么?

这是 .rest 文件

###LOGIN
# @nane loginrequest
POST https://someurl
content-type: application/json

{ "username":"someuser",    "password":"somepassword",  "refresh_token": null }

// THE RESPONSE IS:
//// {
//     "Error": false,
//     "Success": true,
//     "Message": "Login ok.",
//     "Data": {
//       "IdToken": "xxxxx",
//       "RefreshToken": "yyyyy",
//       "AccessToken": "zzzzz",
//       "ExpiresIn": 21600
//     },
//     "ResultCode": 200
//   }

### VARIABLE RESPONSE TO FILL TOKEN
@authtoken= {{loginrequest.response.body.$.Data.AccessToken}

### VCloud Stores API Gateway . GetOrdersIds
GET https://someurl  HTTP/1.1
Content-Type: application/json
Authorization: {{authtoken}}

Using Visual Studio Code and Rest Client Extension:
I am calling an endpoint that returns a JSON object. I'm trying to get the "AccessToken" property of that object, but it doesn't return a value.
What could be doing wrong?

This is the .rest file

###LOGIN
# @nane loginrequest
POST https://someurl
content-type: application/json

{ "username":"someuser",    "password":"somepassword",  "refresh_token": null }

// THE RESPONSE IS:
//// {
//     "Error": false,
//     "Success": true,
//     "Message": "Login ok.",
//     "Data": {
//       "IdToken": "xxxxx",
//       "RefreshToken": "yyyyy",
//       "AccessToken": "zzzzz",
//       "ExpiresIn": 21600
//     },
//     "ResultCode": 200
//   }

### VARIABLE RESPONSE TO FILL TOKEN
@authtoken= {{loginrequest.response.body.$.Data.AccessToken}

### VCloud Stores API Gateway . GetOrdersIds
GET https://someurl  HTTP/1.1
Content-Type: application/json
Authorization: {{authtoken}}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亣腦蒛氧 2025-01-26 22:28:46

我觉得自己像个傻瓜……行尾缺少一个“}”,而且@nane也拼写错误。

感谢@timothy G.

I feel like a fool...it was a missing "}" at end of line and that the @nane was also misspelled.

thanks to @timothy G.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文