Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The next interface of Postman will use the data of the previous interface.

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Problem description:

Now there are two interfaces An and B. The body of response returned by API A has the following structure. I want to take the order_id in rows to interface B.

{"status": 1, "code": 0, "msg": "get * * successful!" , "data": {"rows": [{"order_id": "1493967886001",. }], "pagenation": {"total": "1", "page": "1", "pagesize": "20", "page_offset": 0, "page_total": 1} solution:

1. Set the environment variable in the test of API A

Var data = JSON.parse (responseBody); if (data.status = = 1) {tests ["query success"] = true; postman.setEnvironmentVariable ("order_id", data.data.rows.order_id);} else {tests ["query success"] = flase;}

2. Call `order_ id` in the parameter Body of API B, but I found that if you look at the environment variable, the value of API An is not assigned to the environment variable order_id.

Analysis of problems

There is no problem for me to call other interfaces in the same way, but the difference of this interface is that there is an extra [] in the rows in the response of interface A, so the value has not been successfully assigned to order_id. I have some information about Baidu, and there is no relevant introduction, so I would like to ask you what the solution is.

Try this data.data.rows [0] .order _ id

Or cycle around to find it.

For (var I = 0 * * I < jsonData.data.rows.length;i++) {

Var list = jsonData.data.rows [I]

Tests ["order number" + list.order_id] = list.order_id

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report