邮递员 - 从响应值创建变量
也许作为大多数人,我想让我的工作更容易:)
问题:我想知道是否可以根据我的应用程序后端的响应值创建邮递员的变量。
描述:我的应用程序在邮政请求中生成了数据库的对象,它们基于在表单上输入的数据 - 最简单的表单类型!:
Form data:
name: John
surname: Smith
request: POST /apiUser/create
Body/raw:
name=John&surname=Smith
添加对象后,后端正在为此对象生成ID。在Postman中,我在身体中看到了它,这样:
{
"success": true,
"data": {
"id": 4882
}
}
问题:是否可以从对象的ID创建一个变量?该变量必须存储响应对请求 /apiuser /create生成的ID的值,然后我将创建新的请求 /apiuserimage /uploadimg,这是 - 多亏上述变量 - 将由 /apiuper /create请求在body&gt中生成的cotain ID编号; form-data。
也许有解决此问题的SOM Python程序?
原因:我需要进行上传用户照片的测试,但是为此,我需要在Postman中创建一个新查询:
- post- / apiuser / create
- post - / apiuserimage / uploadimg
Maybe as most of you I want to make my work easier :)
Problem: I wonder if it is possible to create a variable in Postman, based on the value made by the response from my application backend.
Description: My application generates objects for the database in POST request, they are based on the data entered on the form - the simplest type of form!:
Form data:
name: John
surname: Smith
request: POST /apiUser/create
Body/raw:
name=John&surname=Smith
after adding object, backend is generating ID for this object. In Postman I see it in Body, like this:
{
"success": true,
"data": {
"id": 4882
}
}
Question: is it possible to create a variable from the ID of the object? The variable must store the value from ID generated by response to request /apiUser/create and then I will create new request /apiUserImage/uploadImg which - thanks to above variable - will cotain ID number generated by /apiUser/create request in Body > form-data.
Or maybe there are som Python programs which handle this?
Why: I need to do a test of uploading user photos, but for this I need to create a new query in postman:
- POST - / apiUser / create
- POST - / apiUserImage / uploadImg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以手动创建邮递员中的变量,并将其值分配为您在响应中获得的ID。以下是创建和使用变量的步骤:
my_variable
的变量,并给它一个初始值nothing yyouwant
。https://postman-echo.com/get? var = ** {{my_variable}}}**作为URL。徘徊
在变量名称上检查变量的值和范围。
You can manually create a variable in postman and assign it value as the id you get in response. Here are the steps to create and use a variable:
my_variable
and give it an initial value ofanythingYouWant
.https://postman-echo.com/get?var=**{{my_variable}}** as the URL. Hover
over the variable name to inspect the variable's value and scope.