Loop request based on data from response in Postman

  Рет қаралды 59,771

Valentin Despa

Valentin Despa

Күн бұрын

Пікірлер: 139
@vdespa
@vdespa 2 жыл бұрын
Want to have ME be your Postman teacher? 🤔 Here's how: vdespa.com/courses/
@paulc8308
@paulc8308 2 жыл бұрын
Great video Valentin, I've done loops similar to this in the past but I didn't realise the clever trick you can do with Arrays and Objects. Top Tip :) Makes the code cleaner too 👍🏻
@vdespa
@vdespa 2 жыл бұрын
Thanks, Paul. I am glad you have learned something new.
@somechrisguy
@somechrisguy 2 жыл бұрын
I had 80 calls to make, I tried writing some axios js to do this, then gave up and tried postman ‘flows’, gave up on that and was about to start doing them all manually… then I found this video. You saved me a lot of time. Thanks so much.
@vdespa
@vdespa 2 жыл бұрын
You're welcome, I am glad it helped. What was the issue with Postman flows?
@somechrisguy
@somechrisguy 2 жыл бұрын
@@vdespa I just couldn’t work it out, I prefer to use JS code
@shakedown1979
@shakedown1979 2 жыл бұрын
Awesome Valentin, got me around a problem I'd been scratching my head about for a while here!
@vdespa
@vdespa 2 жыл бұрын
You are welcome. Thank you for leaving a comment.
@emilvafin436
@emilvafin436 Жыл бұрын
What an enlightening lesson ! Thank you kind sir
@vdespa
@vdespa Жыл бұрын
Glad you enjoyed it! You are welcome. Thank you for leaving a comment.
@suzannevogt6528
@suzannevogt6528 Жыл бұрын
Perfect. Just what I needed to know.
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.
@shameeraweerasinghe6280
@shameeraweerasinghe6280 Жыл бұрын
Great explanation, you saved my day!
@vdespa
@vdespa Жыл бұрын
Glad to hear it! You are welcome. Thank you for leaving a comment.
@solveitwitharash
@solveitwitharash Жыл бұрын
Great stuff! You are creating great content to help with learning API with Postman! Thank you!
@vdespa
@vdespa Жыл бұрын
Glad you enjoy it! You are welcome. Thank you for leaving a comment.
@vamsikrish3185
@vamsikrish3185 2 жыл бұрын
Same logic is not working for array of strings. Have tried for Id and names. When tried with IDs it's working fine. Is there any other solution to deal with names. Please reply me
@priyankabaheti4675
@priyankabaheti4675 2 жыл бұрын
This video was very helpful. Thank you
@vdespa
@vdespa 2 жыл бұрын
I am glad it helped!
@farhaan2812
@farhaan2812 8 ай бұрын
This is great. Do you have a video of this for XML responses?
@wesleyi.n6463
@wesleyi.n6463 2 жыл бұрын
I can't thank you enough for this great video
@vdespa
@vdespa 2 жыл бұрын
You're very welcome!
@MrManandevil
@MrManandevil 2 жыл бұрын
Sir i don't understand , i followed the same steps as you did but it is saying that response.map is not a function and giving error
@russellstandard4955
@russellstandard4955 2 жыл бұрын
Same here, was there additional dependencies required?
@marklm1
@marklm1 2 жыл бұрын
I am having the exact same problem too. It says response.map is not a function. How do I fix that?
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@connorrich8199
@connorrich8199 2 жыл бұрын
@@vdespa The discord link expired, may I have a new one?
@dmoazzam
@dmoazzam Жыл бұрын
Thank you sm!! What even ChatGPT couldn't help me with, you could! So thank you Valentin. P.S could you share the video recording tool(s) you used? again, thank you!
@vdespa
@vdespa Жыл бұрын
Glad to hear that. OBS.
@revvedupofficial
@revvedupofficial Жыл бұрын
thank you so much, it really helped me a lot
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.
@ვ3ვ3ვ
@ვ3ვ3ვ 2 ай бұрын
I this begginer level, or little bit advanced postmen level?
@LakshithaSamod
@LakshithaSamod 19 күн бұрын
thanks for this. really helpful 🥰
@vdespa
@vdespa 19 күн бұрын
Glad it was helpful!
@peerjee
@peerjee 2 жыл бұрын
Loved it. How can I turn my looping and processing logic that I have written in Postman with your help to a stand alone API tat is running on a Linux box perhaps. Please point me to a course or a lecture you have published. I would love to take a paid course if one exists. Thanks for all you do
@vdespa
@vdespa 2 жыл бұрын
You may want to learn about Newman, which helps you run a Postman collection on any OS. You can't turn a Postman collection into an API. For courses, see the video description.
@RonenMiller
@RonenMiller 3 ай бұрын
Very clear and helpful!
@vdespa
@vdespa 3 ай бұрын
You are welcome. Thank you for leaving a comment.
@nicoaraeugen
@nicoaraeugen Жыл бұрын
Super useful lessons! Well done! I also have a question. I have a POST for inserting some fields, and I want to test if the ID , which is unique, can be inserted twice? How can I run the same request twice? Thank you very much!
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.!
@brendenlang9072
@brendenlang9072 2 жыл бұрын
Great video and explanation!
@vdespa
@vdespa 2 жыл бұрын
Glad you liked it! You are welcome. Thank you for leaving a comment.
@paneerselvam3682
@paneerselvam3682 Жыл бұрын
Hi sir.. can we pass an entire response of a get call as a body to the next post api call?
@Findmanish09
@Findmanish09 Жыл бұрын
Hi.. I have tried this but keeps running with the 0th index value and doesn't exit.
@frsaund06
@frsaund06 Жыл бұрын
Hi, I’ve tried to apply this tutorial to some work I’m doing but my response is a nested object (I’m really new to postman and working with APIs in general but I think this is what it’s called). I need to create an array from one of the fields in this nested object but because the response I’m getting isn’t an array the map function isn’t working. Would it be possible to create a new example that would work off of nested object? If you have this already I’m sorry, I’ve tried to find it but have been unsuccessful thus far. Cheers!
@sebastus27
@sebastus27 2 жыл бұрын
Hello Valentin! I have a question. How can implement a wait function? I am asking because I noticed not all requests are received, at run collection it is the iteration field and there if I put 10 requests I get 4 or 7. How can fix this problem?
@vdespa
@vdespa 2 жыл бұрын
Hello Sebastian: I am not sure I get the problem. At which point do you need to wait?
@hexazan8833
@hexazan8833 Жыл бұрын
thank you , this video was useful
@vdespa
@vdespa Жыл бұрын
Glad to hear that! You are welcome. Thank you for leaving a comment.
@paneerselvam3682
@paneerselvam3682 2 жыл бұрын
Hi Sir, I am having a post request in my collection. When I run the entire collection I need that particular request to be repeated 10 times. So now as per your method i can call that request 10 times, once it is done will the next request in the collection will be continued? Or this statement postman.setNextRequest(null) will stop the collection run?
@vdespa
@vdespa 2 жыл бұрын
Yes, once you have iterated the desired number of times, the next request will be called (unless otherwise indicated).
@AbdelhakKhedhiri-on8fx
@AbdelhakKhedhiri-on8fx Жыл бұрын
Thank you it is very hepful
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.
@СергійКот-э7ф
@СергійКот-э7ф 2 жыл бұрын
Nice tutorial
@vdespa
@vdespa 2 жыл бұрын
Thanks 👍
@rohitw548
@rohitw548 2 жыл бұрын
Such a Fabulous Video
@vdespa
@vdespa 2 жыл бұрын
You are welcome. Thank you for leaving a comment.
@MladjanNjagojevic
@MladjanNjagojevic 2 жыл бұрын
Hey! Great stuff! Thanks. I have a question regrding this. How to filter or find specicic value from a nested array? Response looks like this: [ { "attributes": [ { "id": 54, "name": "Farbe", "options": [ "Grau" ] }, { "id": 57, "name": "Größe", "options": [ "60 x 20 x 1.5 cm" ] }, So, I want to save to a variable the value from "options", but only if the name in an object is "Farbe"? How that function would look like?
@MladjanNjagojevic
@MladjanNjagojevic 2 жыл бұрын
And I forgot to say, position of those nested objects may varay depending on a product. Some products do not have colors (first object in this case has color: this part "Farbe") for instance, so something like: const ean = response.map(data => data.meta_data[2].options[0]); will not work. Actually, it will work, but it will picup different data based on attribute existance.
@vdespa
@vdespa 2 жыл бұрын
You may want to get familiar with the filter function on arrays.
@MladjanNjagojevic
@MladjanNjagojevic 2 жыл бұрын
​@@vdespa Hey! Thanks for getting back. I will research that. If you already have something helpful on this topic in your portfolio, please share it. Or maybe you have just got a new topic for upcoming tutorials... :)
@anvis360tech
@anvis360tech Жыл бұрын
Hi valentine, If I want to pass this id into next call path parameter then do I need to do any change or same script will work . I am getting undefined shift error
@toufiqalam7445
@toufiqalam7445 2 жыл бұрын
Hi valentine, I have two queries, 1. Why did we use "variables" instead of "environment variables" 2. I have 605 id(s), but when ran the collection it ran for 1210 iteration . why is that?
@vdespa
@vdespa 2 жыл бұрын
I have used local variables, as they are no persisted. You can use any type of variables. Start with a smaller data set and use console.log to debug what is going on.
@FantasminhaGames
@FantasminhaGames Жыл бұрын
Great video! How to run collections async?
@md.atifkhan6658
@md.atifkhan6658 2 жыл бұрын
Hey Valentin Why we need to connect database with Postman? what will be the actual scenario when we need to the connect database..and if we will connect database can we do anything in database with postman? what about security and integrity issue.
@vdespa
@vdespa 2 жыл бұрын
I did other tutorials on connecting to a database. See my channel.
@shubhamwalia5118
@shubhamwalia5118 2 жыл бұрын
Hey Valentin! First and foremost the video is really helpful and informative. I have landed into an error that I'm not able to fix on my own and thought you might be able to assist. I'm getting the error TypeError: Cannot read property 'shift' of undefined when I execute the Run Collection. In GET tests script section I have below code: const response = pm.response.json(); const tagnamess = response.map(tagname => tagname.name); console.log(tagnamess); pm.variables.set('tagnamess',tagnamess); And in POST pre-request script section I have below code: const namess = pm.variables.get('namess'); pm.variables.set('currentnamess', namess.shift()); And in the POST request body section i have below: { "tag": { "name": {{currentnamess}} } } What is that I'm missing? Please treat that as urgent, thanks!
@shubhamwalia5118
@shubhamwalia5118 2 жыл бұрын
@valentin despa, can you please check this?
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@soiletsstelios8533
@soiletsstelios8533 2 жыл бұрын
I want to make an add-on program that monitors the console (listens), separates some commands and sends them back to the server.
@tmanrx7
@tmanrx7 2 жыл бұрын
Brilliant video 👍
@vdespa
@vdespa 2 жыл бұрын
Glad you enjoyed it
@hooyah
@hooyah 2 жыл бұрын
Hi valentin. I want to know how i push response into variable. Here example. Va is virtual account 1. Post create virtual account 2. Get the VA number then Push VA number to variable. 3. Repeat process 1 and 2 until all bank VA is created or 5 times. I stuck at this. I need va number foranother request in my api.
@vdespa
@vdespa 2 жыл бұрын
You may need to learn a few Postman basics before getting into scripting. See the video description for courses and other tutorials.
@helpothers6751
@helpothers6751 2 жыл бұрын
i have list of items but shift() method always it's taking first value in the list please guide me
@vdespa
@vdespa 2 жыл бұрын
Which value is it taking?
@paneerselvam3682
@paneerselvam3682 2 жыл бұрын
Hi Sir, we are getting an array of values and passing one by one in the next request using shift function... Is there a possibility to pass the value in the reverse order? I mean if I have an array of values [12345] then i have to pass 5 in the first request and 4 in the second run. Can you please help me?
@vdespa
@vdespa 2 жыл бұрын
Instead of shift(), you can use pop()
@paneerselvam3682
@paneerselvam3682 2 жыл бұрын
@@vdespa Thank you very much 👍
@honeybhatia9901
@honeybhatia9901 2 жыл бұрын
Hi If I save the values in CollectionVariable or environment variable then it always return first vlaue and shift function not working. Its only working with local varible.
@vdespa
@vdespa 2 жыл бұрын
I doubt this is the case. Double check your code, use console.log to debug.
@rajusjohn1
@rajusjohn1 2 жыл бұрын
I have 1 GET request and 2 PUT requests in the collection.How do I pass the same variable in the second PUT request? variable is passing only in the first PUT request
@vdespa
@vdespa 2 жыл бұрын
Once you get a variable, it is available in all upcoming requests.
@rohitw548
@rohitw548 2 жыл бұрын
Valentin - I need your help please. Problem - I am Running a Post request to create a Loan 1 by sending L1 in the request. Similarly I need to test Loan types from L1 to L13. These loan types will be created using the same Post request, just by replacing L1 with L2 or L3 or L3 and so on. I am passing the loan types in CSV file as shown in your video. And it works as expected. I see that for 13 types of loan types, I get 13 iterations in my html reporter. Which is again as expected. But how do I merge those 13 iterations into 1 iteration. How do I create a report which will just have 1 iteration, which will display the results for all 13 loan types. Let me know please
@vdespa
@vdespa 2 жыл бұрын
If the data is coming from a CSV file, you can't read the entire data set at once. This is why you have 13 iterations.
@rohitw548
@rohitw548 2 жыл бұрын
@@vdespa can I merge 13 iterations into 1 if I use a Json file as a input
@hangeryouhen3311
@hangeryouhen3311 2 жыл бұрын
It's very useful, thank you!
@vdespa
@vdespa 2 жыл бұрын
Glad it was helpful!
@victorious_2230
@victorious_2230 Жыл бұрын
Hi.brother, I my collection there are four request First is auth Second is init Third is logic Fourth is end So i want to run third and fourth request multiple times(eg:10) ,how i can do this(third request contains session id which need to passed to fourth and then from fourth request session id need to be passed to third requestm)
@vdespa
@vdespa Жыл бұрын
Look into setNextRequest
@ShruthiPamadi
@ShruthiPamadi Жыл бұрын
Hi , I am facing issue in handling workflow. "postman.setNextRequest()" is going infinite loop even though there is stop workflow code postman.setNextRequest(null);. Here is my piece of code. if(Array.isArray(req) && req.length>0) { postman.setNextRequest('Create Patient');//my post API name-Create Patient } else if(requestArray.length==0){ postman.setNextRequest(null); } req is my array which has multiple entries in it. Great if you could help in resolving . Thanks in advance.
@vdespa
@vdespa Жыл бұрын
ADD some console.log statements to your code to better understand what is going on.
@nikolaurevac7175
@nikolaurevac7175 2 жыл бұрын
Thanks for this video! If I run my collection, it still executes previous request each time as well. How to set to execute only second call in multiple times?
@vdespa
@vdespa 2 жыл бұрын
Hard to say. Double check your setNextRequst value.
@nikolaurevac7175
@nikolaurevac7175 2 жыл бұрын
@@vdespa Do you know how to write a script for creating a csv file on desired location and fill it by the variable values that I created in Tests of request?
@vdespa
@vdespa 2 жыл бұрын
@@nikolaurevac7175 You can't do that in Postman. Search my channel for a CSV tutorial.
@krystofhornik6665
@krystofhornik6665 2 жыл бұрын
How would you extract ids being the response object, not an array?
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Consider posting your question in the Postman community (community.postman.com/) and share what you have tried so far and where did you get stuck. Include screenshots and as many details as possible. Feel free to tag me with @vdespa. Thanks!
@SalmaKhalil-j2u
@SalmaKhalil-j2u 8 ай бұрын
Thanks A lot😍🤩
@vdespa
@vdespa 8 ай бұрын
You're welcome 😊 Thank you for leaving a comment.
@midnightoilgames9796
@midnightoilgames9796 5 ай бұрын
awesome help! well explained. that intro is way too corny! lol
@vdespa
@vdespa 5 ай бұрын
Glad you liked it! Thank you!
@jarrodmcguire2508
@jarrodmcguire2508 2 жыл бұрын
So handy, thanks.
@vdespa
@vdespa 2 жыл бұрын
I am glad that you liked it!
@royandre-davidkoupoh9015
@royandre-davidkoupoh9015 Жыл бұрын
Good video
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.
@paneerselvam3682
@paneerselvam3682 2 жыл бұрын
Hi sir.. can we pass an array of values as query param in postman... For each of the value in array i will have the decoded value in the response. Can i get those values as array. For eg i have array ["Arun","Kumar","Raj"].. for each of this value.. i will have a decoded value in response. I have to get those values in another array. Could you please help with this. 🙂
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Consider posting your question in the Postman community (community.postman.com/) and share what you have tried so far and where did you get stuck. Include screenshots and as many details as possible. Feel free to tag me with @vdespa. Thanks!
@paneerselvam3682
@paneerselvam3682 2 жыл бұрын
Hi Sir, I have two clarifications. 1. If I get a array [1,2,3] in a response how to pass the array in another request as [3,2,1]. 2.. If I get a array [1,2,3] in a response how to pass the array in another request as [ 1, 2, 3 ].
@vdespa
@vdespa 2 жыл бұрын
You can use JavaScript to transform the array to your needs.
@niamularifin6799
@niamularifin6799 6 ай бұрын
Great Video
@vdespa
@vdespa 6 ай бұрын
Glad you enjoyed it. Thank you!
@笑看天下-d6c
@笑看天下-d6c 2 жыл бұрын
Hello . But why postman show me the Response.map not a function?
@vdespa
@vdespa 2 жыл бұрын
Probably because it is not an array
@笑看天下-d6c
@笑看天下-d6c 2 жыл бұрын
@@vdespa how can I check array is true ?
@hbk666
@hbk666 2 жыл бұрын
you saved my day! thanks a lot~!
@vdespa
@vdespa 2 жыл бұрын
Glad to hear that! Happy to help.
@nabinupreti3416
@nabinupreti3416 2 жыл бұрын
TypeError: Cannot read properties of undefined (reading 'shift')
@vdespa
@vdespa 2 жыл бұрын
Check your code, use console.log to make sure the property you are using exists.
@balajicmb1132
@balajicmb1132 2 жыл бұрын
How to updates multiple records multiple updates postman to postgresql sqlalchemy ?
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@olelobyco7539
@olelobyco7539 6 ай бұрын
Nice, but it doesn't work :(
@MrManandevil
@MrManandevil 2 жыл бұрын
Please help me Valentin I am unable to run tests in Postman even after following the exact same steps, if you would just connect with me for a 5 min session then I would be grateful.
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@RayZorJ3lade1
@RayZorJ3lade1 12 күн бұрын
I thnk this is no longer accurate pm.variables is now pm.collectionVariables
@vdespa
@vdespa 12 күн бұрын
@@RayZorJ3lade1 No, it's still accurate. Thanks for asking.
@jopadjr
@jopadjr 2 жыл бұрын
46th...Thanks
@vdespa
@vdespa 2 жыл бұрын
46th what?
@jopadjr
@jopadjr 2 жыл бұрын
@@vdespa It means Im the 46th who smashed the like button
@vdespa
@vdespa 2 жыл бұрын
@@jopadjr thanks 👍 keep it coming for other videos. You are the best
@jopadjr
@jopadjr 2 жыл бұрын
@@vdespa sure...I'm learning a lot from you mate.. Keep up the good work.. Cheers !!!
@mTz0KS43
@mTz0KS43 2 ай бұрын
Looking forward for a remake using postman flows🫡
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
Apple peeling hack @scottsreality
00:37
_vector_
Рет қаралды 129 МЛН
How To Get Married:   #short
00:22
Jin and Hattie
Рет қаралды 11 МЛН
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 159 М.
Postman Data Driven Testing with CSV Data File | Postman Testing Tutorial
17:20
SDET Unicorns by Dilpreet Johal
Рет қаралды 11 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 808 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 806 М.
Data-driven testing with different data sets for each request
16:48
Valentin Despa
Рет қаралды 16 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 631 М.
API vs. SDK: What's the difference?
9:21
IBM Technology
Рет қаралды 1,4 МЛН
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 272 М.
Postman Api Testing Tutorial for beginners
16:45
Codemify
Рет қаралды 35 М.