Loop request based on data from response in Postman

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024

Комментарии • 134

  • @vdespa
    @vdespa  2 года назад +2

    Want to have ME be your Postman teacher? 🤔
    Here's how: vdespa.com/courses/

  • @paulc8308
    @paulc8308 2 года назад +6

    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

  • @RonenMiller
    @RonenMiller 2 месяца назад

    Very clear and helpful!

    • @vdespa
      @vdespa  2 месяца назад

      You are welcome. Thank you for leaving a comment.

  • @shakedown1979
    @shakedown1979 2 года назад +1

    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.

  • @suzannevogt6528
    @suzannevogt6528 Год назад +1

    Perfect. Just what I needed to know.

    • @vdespa
      @vdespa  Год назад

      You are welcome. Thank you for leaving a comment.

  • @emilvafin436
    @emilvafin436 Год назад +1

    What an enlightening lesson ! Thank you kind sir

    • @vdespa
      @vdespa  Год назад

      Glad you enjoyed it! You are welcome. Thank you for leaving a comment.

  • @shameeraweerasinghe6280
    @shameeraweerasinghe6280 Год назад +1

    Great explanation, you saved my day!

    • @vdespa
      @vdespa  Год назад

      Glad to hear it! You are welcome. Thank you for leaving a comment.

  • @wesleyi.n6463
    @wesleyi.n6463 2 года назад +2

    I can't thank you enough for this great video

    • @vdespa
      @vdespa  2 года назад

      You're very welcome!

  • @brendenlang9072
    @brendenlang9072 2 года назад +1

    Great video and explanation!

    • @vdespa
      @vdespa  2 года назад

      Glad you liked it! You are welcome. Thank you for leaving a comment.

  • @priyankabaheti4675
    @priyankabaheti4675 2 года назад +1

    This video was very helpful. Thank you

    • @vdespa
      @vdespa  2 года назад

      I am glad it helped!

  • @arashitook6784
    @arashitook6784 Год назад

    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.

  • @revvedupofficial
    @revvedupofficial Год назад +1

    thank you so much, it really helped me a lot

    • @vdespa
      @vdespa  Год назад +1

      You are welcome. Thank you for leaving a comment.

  • @rohitw548
    @rohitw548 2 года назад +1

    Such a Fabulous Video

    • @vdespa
      @vdespa  2 года назад

      You are welcome. Thank you for leaving a comment.

  • @user-uw5qg3yo5l
    @user-uw5qg3yo5l 2 года назад +3

    Nice tutorial

    • @vdespa
      @vdespa  2 года назад +1

      Thanks 👍

  • @hexazan8833
    @hexazan8833 Год назад +1

    thank you , this video was useful

    • @vdespa
      @vdespa  Год назад

      Glad to hear that! You are welcome. Thank you for leaving a comment.

  • @AbdelhakKhedhiri-on8fx
    @AbdelhakKhedhiri-on8fx Год назад +1

    Thank you it is very hepful

    • @vdespa
      @vdespa  Год назад

      You are welcome. Thank you for leaving a comment.

  • @tmanrx7
    @tmanrx7 2 года назад +1

    Brilliant video 👍

    • @vdespa
      @vdespa  2 года назад +1

      Glad you enjoyed it

  • @hangeryouhen3311
    @hangeryouhen3311 2 года назад

    It's very useful, thank you!

    • @vdespa
      @vdespa  2 года назад

      Glad it was helpful!

  • @user-in5wp8yo2i
    @user-in5wp8yo2i Месяц назад +1

    I this begginer level, or little bit advanced postmen level?

  • @user-wc8nx9vm7g
    @user-wc8nx9vm7g 7 месяцев назад

    Thanks A lot😍🤩

    • @vdespa
      @vdespa  7 месяцев назад

      You're welcome 😊 Thank you for leaving a comment.

  • @jarrodmcguire2508
    @jarrodmcguire2508 2 года назад

    So handy, thanks.

    • @vdespa
      @vdespa  2 года назад

      I am glad that you liked it!

  • @farhaan2812
    @farhaan2812 7 месяцев назад

    This is great. Do you have a video of this for XML responses?

  • @niamularifin6799
    @niamularifin6799 5 месяцев назад

    Great Video

    • @vdespa
      @vdespa  5 месяцев назад

      Glad you enjoyed it. Thank you!

  • @royandre-davidkoupoh9015
    @royandre-davidkoupoh9015 Год назад +1

    Good video

    • @vdespa
      @vdespa  Год назад

      You are welcome. Thank you for leaving a comment.

  • @hbk666
    @hbk666 2 года назад

    you saved my day! thanks a lot~!

    • @vdespa
      @vdespa  2 года назад

      Glad to hear that! Happy to help.

  • @vamsikrish3185
    @vamsikrish3185 2 года назад +1

    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

  • @MrManandevil
    @MrManandevil 2 года назад +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 года назад +1

      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?

  • @Findmanish09
    @Findmanish09 Год назад

    Hi.. I have tried this but keeps running with the 0th index value and doesn't exit.

  • @dmoazzam
    @dmoazzam Год назад +1

    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  Год назад +1

      Glad to hear that. OBS.

  • @midnightoilgames9796
    @midnightoilgames9796 4 месяца назад

    awesome help! well explained. that intro is way too corny! lol

    • @vdespa
      @vdespa  4 месяца назад

      Glad you liked it! Thank you!

  • @peerjee
    @peerjee 2 года назад +1

    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.

  • @FantasminhaGames
    @FantasminhaGames Год назад

    Great video! How to run collections async?

  • @paneerselvam3682
    @paneerselvam3682 Год назад

    Hi sir.. can we pass an entire response of a get call as a body to the next post api call?

  • @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.!

  • @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!

  • @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.

  • @MladjanNjagojevic
    @MladjanNjagojevic 2 года назад +1

    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 года назад +1

      ​@@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

  • @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?

  • @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.

  • @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 года назад +1

      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.

  • @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?

  • @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.

  • @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!

  • @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.

  • @victorious_2230
    @victorious_2230 11 месяцев назад

    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  11 месяцев назад

      Look into setNextRequest

  • @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.

  • @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.

  • @olelobyco7539
    @olelobyco7539 5 месяцев назад +1

    Nice, but it doesn't work :(

  • @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 года назад +1

      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 года назад +2

      @@nikolaurevac7175 You can't do that in Postman. Search my channel for a CSV tutorial.

  • @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 года назад +1

      Yes, once you have iterated the desired number of times, the next request will be called (unless otherwise indicated).

  • @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.

  • @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

  • @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 года назад +1

      You can use JavaScript to transform the array to your needs.

  • @user-vm4id5gi4x
    @user-vm4id5gi4x 2 года назад

    Hello . But why postman show me the Response.map not a function?

    • @vdespa
      @vdespa  2 года назад

      Probably because it is not an array

    • @user-vm4id5gi4x
      @user-vm4id5gi4x 2 года назад

      @@vdespa how can I check array is true ?

  • @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 👍

  • @shubhamwalia5118
    @shubhamwalia5118 2 года назад +1

    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.

  • @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 года назад +1

      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!

  • @balajicmb1132
    @balajicmb1132 2 года назад

    How to updates multiple records multiple updates postman to postgresql sqlalchemy ?

    • @vdespa
      @vdespa  2 года назад +1

      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.

  • @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.

  • @jopadjr
    @jopadjr 2 года назад

    46th...Thanks

    • @vdespa
      @vdespa  2 года назад

      46th what?

    • @jopadjr
      @jopadjr 2 года назад +1

      @@vdespa It means Im the 46th who smashed the like button

    • @vdespa
      @vdespa  2 года назад +1

      @@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 Месяц назад

    Looking forward for a remake using postman flows🫡