Postman - Running a request multiple times with different data sets (API testing)

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2017
  • In this video, I will show you how you can take advantage of pre-request scripts and workflows in Postman to submit the same request over and over again but with different data each time.
    Please note that postman.setNextRequest method takes the name of your next request as a parameter. This example only works because the request URL happens to be the same as the request name. But it does not have to be an URL, it is just a name.
    If this was helpful and you want to support me create more videos like this one, please consider subscribing.
    👉 / @vdespa
    --
    ⭐️ 🎓 The complete guide to Postman (online course) ⭐️
    Want to learn more about Postman? Check my Postman online course.
    Get it at a special price and help support this RUclips channel:
    vdespa.com/courses/
    --
    ⭐️ 💬 I have a question. ⭐️
    I do my best to answer all comments here on RUclips but I cannot make any guarantees.
    If you have a question, it is best to ask your question on Discord, on the Postman User Group on Facebook, or on the Postman Community (links below).
    If you are asking a question, make sure to include as many details as possible, including screenshots.
    If you have purchased the Postman online course, please use the Q&A section or send me a message directly.
    Please do not email me or contact me on other channels as I might not be able to answer. Sorry!
    --
    ⭐️ 💡 I have a video idea ⭐️
    Do you want me to create a video on a specific topic? Just fill out the form below:
    forms.gle/uWEzXFQ2viJtZtvZ7
    --
    ⭐️ 📺 Learn Postman on RUclips ⭐️
    Collection of video tutorials:
    ▸ Learn Postman | bit.ly/2CFaf70
    ▸ Postman Crash Course | bit.ly/2YwEBBT
    ▸ Postman Tips & Tricks | bit.ly/2JLkXyU
    ___
    ⭐️ 📕 Free resources ⭐️
    📌 DOWNLOAD the FREE Postman Quick Reference Guide
    bit.ly/postman-quick-reference-yt
    📌 Ask a question on Discord (unofficial)
    / discord
    📌 Join the Postman User Group on Facebook (unofficial)
    bit.ly/2OutAMZ
    📌 Postman community forum (official)
    community.getpostman.com/
    --
    ⭐️ 📩 Contact & Imprint ⭐️
    👉 Let's be friends
    sendfox.com/lp/1dv56d
    👉 Follow me on Twitter:
    / vdespa
    👉 Follow me on Medium:
    / vdespa
    👉 Follow me on Facebook:
    / valentin-despa-1130381...
    👉 Let's connect on LinkedIn:
    / vdespa
    vdespa.com/imprint

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

  • @vdespa
    @vdespa  4 года назад +3

    Download the FREE Postman Quick Reference Guide
    👉 www.subscribepage.com/postman

  • @VictorDabela
    @VictorDabela 5 лет назад +2

    Great video!
    It helped me a lot to solve some massive integration problem with multiple customers.
    Thanks!

  • @RoryGaddin
    @RoryGaddin 4 года назад +1

    Thanks Valentin, I found this tutorial very useful. Well explained and easy to follow.

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

      I am glad it was helpful, Rory! Thanks for your comment.

  • @jackofalltrademasterofsome
    @jackofalltrademasterofsome 4 года назад +1

    Excellent one. Helped me in a very tight situation. Thanks.

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

      Glad to hear that! Thank you for your comment.

  • @theraahi_in
    @theraahi_in 3 года назад +1

    Short and crisp. Thank you! :)

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

      I am glad it matched your expectations. Thanks

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

    More Useful and thanks for covering the scenario which I am looking for, Much Appreciated

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

      Glad it was helpful! You are welcome.

  • @OliverUnderTheMoon
    @OliverUnderTheMoon 5 лет назад +2

    Thank you for this helpful video. I chose to use:
    if (companies instanceof Array && companies.length > 0) {
    and:
    if (!(companies instanceof Array)) {
    instead of truthy evaluation because maybe some non-array value could evaluate to true.

  • @ThiagoSPassos
    @ThiagoSPassos 5 лет назад

    Great video! Thanks for sharing.

  • @nghiavoai7993
    @nghiavoai7993 4 года назад +1

    Thank you very much, this is the exactly what tip I need right now!

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

      Great to hear!

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

    Thank you very much!! this is exactly I am looking....getting after a lot of searches.

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

      Glad I could help! You are welcome. Thank you for leaving a comment.

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

    Great Tutorial, this was super helpful!

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

      Glad it was helpful!

  • @ElPachonsito
    @ElPachonsito 4 года назад +2

    Michas gracias, me ayudo mucho con este ejemplo para aplicarlo. Excelente tutorial

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

      ¡Gracias por tu comentario! Me alegro de que el tutorial haya sido útil.

  • @brpctips
    @brpctips 5 лет назад

    Great Video!!!!!!! Thanks for the tips!!

    • @apnvinobala1
      @apnvinobala1 5 лет назад

      Nice, in mobile its not visiable. Kindly post the script

  • @chandu122333
    @chandu122333 4 года назад +1

    Thanks Valentin. Very useful one

  • @jgowrri
    @jgowrri 6 лет назад

    Very thanks. I was trying the similar concept and got stuck you helped me. Btw how do we define pm.environment? i am using the full syntax all the time?

  • @patriciapaez3233
    @patriciapaez3233 9 месяцев назад

    Thank you very much. Do you have some material for learning how to make concurrent multiple requests? Thanks in advance.

  • @jpeca13
    @jpeca13 4 года назад +3

    Your Postman related tutorials are great. Related to this one I do not understand the advantage of the pre-request script instead of using data file when running a collection. Seems easier for me to create a csv/json file and select it in Collection Runer.

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

      Thank you for your comment. Regarding you remark, you are right. What I am showing is relevant when the iteration data comes from a previous request. The pre-request script was just a way to store it.

  • @ankajgoyal8197
    @ankajgoyal8197 4 года назад

    How can i achieve this if i am having multi-form data instead of raw json and file needs to be selected from the file directory.
    Thanks

  • @gattupalli690
    @gattupalli690 4 года назад +1

    Thanks so much. This was such a respite for me where I had to run the APIs for 100 property ids. I could do it

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

    Awesome. You saved my day, liked and subscribed your channel :)

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

      Glad I could help! You are welcome. Thank you for leaving a comment.

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

    Excellent Brother.

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

      Thank you. I really appreciate it.

  • @MaximeBodivit
    @MaximeBodivit 4 года назад

    Thanx Valentin ;) !

  • @MsTwte
    @MsTwte 3 года назад

    @ Valentin Despa inside the if statement in the "pre-request script" you're redeclaring the variable companies. this cause alot of issue for me but it's solved by simply removing the "var" keyword inside the if statement

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

      Glad you have found a solution. Thanks for letting me know.

  • @chiranjibghorai6950
    @chiranjibghorai6950 5 лет назад +3

    Excellent tutorial. Postman could simplify the workflow though, something like just executing a JSON of request strings and then generate an output file in the end

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

      Sure, there are many ways. Please check the router tutorial. That one shows a different approach. Thanks for the comment.

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

    Would you recommend this technique when testing for different result codes? E.g. Checking 200, 401, 404 based on parameter values.

  • @Pativerus
    @Pativerus 5 лет назад

    Thanks!

  • @pearlking
    @pearlking 3 года назад +1

    Thank you very much!

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

      You're welcome!

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

    Thanks for sharing

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

      Thanks for watching!

  • @Kevin-ym3xg
    @Kevin-ym3xg 2 года назад +1

    REALLY THANKS

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

      Most welcome

  • @abhigupta9727
    @abhigupta9727 4 года назад

    Amazing video . Thank you ! Could you please confirm if you have video for reading the data sets from CSV/Spreadsheet for data driven automation ?

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

      Yes. There should be at least one video on this topic.

    • @abhigupta9727
      @abhigupta9727 4 года назад

      @@vdespa - Thanks . Could you please point the video

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

    is it possible to do the same without collection runnet , just scripts in postman ? to save multiple datasets from csv file?

  • @ankurvishwakarma7776
    @ankurvishwakarma7776 3 года назад

    Hey, it is not working for multiple iterations if there is only single request in the collection

  • @davidjunghan91
    @davidjunghan91 4 года назад +2

    This is awesome

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

      Thank you for your comment!

  • @rallysahil
    @rallysahil Месяц назад

    HOw can I execute same api with diiferent files in a folder. Each file is selected in the upload field as binary data ?

  • @scavalpha5211
    @scavalpha5211 4 года назад +1

    you Da MVP. thanks

  • @1902garimatiwari
    @1902garimatiwari Год назад

    Hi,
    Can you suggest a solution for the below requirement
    I need to form the request body from the json files present on a certain path, each json file is a separate request body.
    And also the number and names of files may vary.

  • @sibanidevi930
    @sibanidevi930 14 дней назад

    I am unable to pass multiple values using the approach mentioned in the video ,its only executing first value provided once only

  • @CodeByB
    @CodeByB 3 года назад

    Thanks

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

      You are welcome!

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

    Hello VAlentin - so this example is basically 1 iteration is set on the collection runner - but internaly the request itself loops to 3 times based on the array length ?? correct me if i understood wrong

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

    What should i do when i have multiple variables to be changed. Example company name and address

  • @lizalinnayak1029
    @lizalinnayak1029 4 года назад +1

    Thanks Valentine, I found it very useful..Also can it be possible with multiple services with different testdata run at a time?

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

      Thanks for your comment. Can you give me an example. I don't know what you mean.

    • @lizalinnayak1029
      @lizalinnayak1029 4 года назад

      @@vdespa I was able to do it now by watching one of your video with CSV file.. Thanks for your response...👍

  • @ManishBhati
    @ManishBhati 5 лет назад

    hi @Valentin, I need to run a request URL (has dynamic values with simple auth) multiple times to get stats as 200, 400, 401, 404 on a single run. Please describe with an example

    • @ManishBhati
      @ManishBhati 5 лет назад

      @@vdespa , ok I will try and I bought all your videos from Udemy

  • @alextreme98
    @alextreme98 6 лет назад +1

    Put the request name inside the setNextRequest surrounded by ' ' not " " ... it won't work otherwise

  • @hanumansays3725
    @hanumansays3725 4 года назад

    Very good - but extremely quick. I am unable to see the commands in the script before you skip to the next step. It helps if you can share this collection as a JSON for us to check the commands.

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

      Sorry for that, I will keep that in find for future videos.

    • @hanumansays3725
      @hanumansays3725 4 года назад

      @@vdespa Thanks a lot for the response :)

  • @amitmokashi2388
    @amitmokashi2388 4 года назад

    Do you know, if we can pass elements from excel file & verify against another excel file?

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

      I don' thinks would be possible.

  • @victorregoz
    @victorregoz 5 лет назад

    does this works in the monitor (sandbox)? I need to set up a loop just like this in a monitor, I read that postman.* operations do not work on the sandbox.

    • @victorregoz
      @victorregoz 5 лет назад

      @@vdespa Hi, I asked directly to the forum and I misunderstood something, what is not available in the sandbox are some dynamic variables apparently but postman should work. Thanks for your concern!

  • @lucaspiresnabais877
    @lucaspiresnabais877 4 года назад

    Is there a way to do this exact same but using the console runner newman?

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

      Yes, you can also use newman for this.

  • @Red999u
    @Red999u 3 года назад

    I've recently started using Insomnia Core rather than Postman but it's missing some key features. Is there a feature similar to the Postman Collection runner feature i can set up in Insomnia?

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

      Sorry, I don't use Insomnia.

  • @antoniorodrigo897
    @antoniorodrigo897 4 года назад

    Works only if Collection Runner is used. Outside Collection Runner screen, test will run only once

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

      This is expected as the Postman workflows can only work if you automate (Collection Runner, Newman).

  • @doyourworkout5608
    @doyourworkout5608 3 года назад +1

    Nice example but it gets a little messy if you have a very elaborate JSON body which you iteratively adapt according to a array (or multiple). Is it possible to use an external file for this as well? Let’s say CSV or XML?

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

      This example assumes this data comes from another endpoint (I should have said that). You can use CSV or JSON. See other tutorials on this channel.

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

      @Adam Schomaker As far my understanding it can only be achieved using Collection runner which might not make sense in a lot of cases tbh

  • @stars-and-clouds
    @stars-and-clouds 2 года назад

    I need to paginate to get all the data from an API, for example:
    500 names per page and start from 501 next request until we reach 170K, so 340 requests. How do I increase the offset parameter by 500 each time?

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

      Have you tried using a variable to store the last entry number?

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

    Great video and information. I stuck in one place of API automation : I am getting an otp verification URL in one of my API response and I am opening the URL manually in one browser to enter the OTP, how to automate it because without automating this step my next request is failing. Please help me.

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

      If you need manual intervention, you can't automate this with Postman. You may need to use another e2e tool like Cypress (or something) to do that UI interaction. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.

  • @ezekieludoh6735
    @ezekieludoh6735 4 года назад +2

    Hi Valentin, thanks for the tutorial. It was awesome. I guess what I would need some pointers on is how to write tests for each new NAME you are passing into theAPI requests. Something like: if the name is "Google", assert the response is 200, if the name is "Facebook", assert the response is 409. How can I loop through tests per request value?

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

      Thank you for your comment. You just need to replace 200 with a variable. This will help make your tests dynamic.

    • @ezekieludoh6735
      @ezekieludoh6735 4 года назад

      @@vdespa Thanks for that pointer. I may as well declare an array of responses that match my array of inputs. This way, I can use the same SHIFT method to assert the expected result...

  • @zom786
    @zom786 8 месяцев назад +1

    Thanks for the guide. I followed it from the start to finish, however when I try to run the collection, my request is executed only once and I see the "No tests found" message. Any ideas what is wrong?

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

      "No tests found" appears when there are no tests.

    • @yogitzz.kulawade253
      @yogitzz.kulawade253 4 месяца назад

      I also faced the same issue: it shows no tests

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

    Hey , I need to convert the string which I am passing in base 64 ,so how can i send multiple data with base 64.

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

      Base64 is just the encoding. The principle stays the same. You may also want to look into creating a CSV or JSON file with the iteration data.

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

    I have followed your example exactly as you've coded, but my post only runs once and stops after Google.

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

      Use console.log to debug your script.

  • @poojanimodiya7998
    @poojanimodiya7998 4 года назад

    I have tried using this approach but did not work for me as expected. While running through collection runner, request runs only once and to run with next set of data i need to run collection again. Is it something i am missing that you could help? Thanks in advance.

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

      It is hard to know what the problem is in this case. Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.

  • @sukanyashide9188
    @sukanyashide9188 3 года назад

    #need help
    Instead of uploading files during Run, can we provide a URL so every time I don't need to upload files?

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

      If you are testing a file upload, you need to actually upload a file otherwise your test is useless.

  • @dhavaljardosh
    @dhavaljardosh 5 лет назад

    How can I pass a whole object as variable instead of just passing it as a value in Key-Value pair?
    What I mean is instead of passing ----- "name": {{companies}} ------- . can I pass only ----- {{company_object}} ------, where company_object = {"name": "Company Name"}..

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

    I have thousands of JSON objects that I need to post to my Google Cloud Storage. When I run my collection following this guide, it takes a very long time to get every JSON object inside since each request is a single JSON object that takes 200 ms. Is there a way to speed this process up? Would it be something like batching the HTTP requests?

    • @1902garimatiwari
      @1902garimatiwari Год назад

      Hi Cannot
      Did you get the solution ? I also have a similar kind of issue.

  • @1241GIBEK
    @1241GIBEK 3 года назад

    I got error ' the request does not have any test '

  • @dickshachohan3583
    @dickshachohan3583 5 лет назад

    Thanks for this video. It helps alot!!! I have a doubt, Now I have 2 variables (list) instead of 1 (list) (in your case companies) . I want to send the variable to body section one by one . I have tried but not able to do. Could you please help me.. Thanks in advance!!!

    • @dickshachohan3583
      @dickshachohan3583 5 лет назад

      @@vdespa now in my body section there are 2 variables instead of 1 like in your case it is company and in my case time period and role. how i can send these 2 variable in nested loop like for 1 time period all roles will go and then for 2nd time period all the roles will go again. Thanks in advance!!

    • @dickshachohan3583
      @dickshachohan3583 5 лет назад

      @@vdespa i tried it but somewhere i am going wrong.. It would be great if you could help me. Thanks in advance!!!

  • @sowmyakalvagadda6711
    @sowmyakalvagadda6711 4 года назад +2

    I am using the same code to insert [ "7666","3333","6667"] values and running through collection runner but I see only one request being called and the other are not even shown. Please help me

    • @sowmyakalvagadda6711
      @sowmyakalvagadda6711 4 года назад +1

      I changed the iteration number to multiple times in collection runner and it's accepting multiple values in arrray. Does this make sense?

    • @Danish-797
      @Danish-797 4 года назад

      @@sowmyakalvagadda6711 : this wont help, your solution to set the iteration doesn't solve the purpose.

    • @jigneshpatel147
      @jigneshpatel147 3 года назад

      yes same-thing for me. it's run only once

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

      Changing iteration number helped me

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

    @valetin Despa, I have to set the response data values for different requests in same environment variable. Is it possible? (Ex environment variable: values : 1,2,3,4). Do we have any method instead of pm.environment.set(). Set method is updating with new value. I need to add multiple values to same variable.

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

      If you need to add multiple values to same variable, you may want to use an array to store this.

  • @zeenatahmed598
    @zeenatahmed598 4 года назад

    I am new to Postman and running into a recurrent issue that I can’t figure out. I am trying to run the same request multiple times using an array of data established on the Pre-request script, however, when I go to the runner the request is only running once, rather than 3 times.
    Can somebody help

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

      It is hard to know what the problem is in this case. Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.

  • @subashskj83
    @subashskj83 4 года назад +1

    in the Data Set Result, why the PASSED and FAILED is ZERO??

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

      Good question. This is because I haven't written any tests.

  • @pandemonium8276
    @pandemonium8276 4 года назад

    Hello Valentin, how are you?
    I was trying to do this in one of my tests but it doesn't work. Did something change and it's not possible to do it anymore?
    THanks

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

      Please check again your code. This should still work.

    • @manikandanp2409
      @manikandanp2409 4 года назад

      @@vdespa Yes, i just verified and working.

    • @manikandanp2409
      @manikandanp2409 4 года назад

      I did a mistake too. That was postman.sendNextRequest("reqName") instead of postman.setNextRequest("reqName");

  • @w3worker
    @w3worker 5 лет назад

    And what if we need to execute each company request at a time instead of requesting one by one?
    Actually i am working on a forex auto trading project and need to send buy requests to the websocket api server for multiple clients at a specific live market price at a time.
    And if it executes one after one as you described, means each client's buy requests will be at different market prices.
    Do u have any solution how to achieve? I am moving around batching MAP

    • @w3worker
      @w3worker 5 лет назад

      @@vdespa Yes i know that...
      Asked u bcz i thought u might have any solution regarding my query. Currently i am using jQuery for my websockets but can also move to c# if that fix my issue.
      Waiting for ur valuable response...

    • @w3worker
      @w3worker 5 лет назад

      @@vdespa oh okay

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

    Hi, very useful but you missed one little part that makes it impossible to retry and repopulate the variables.
    You need to check in the if in the pre-request script : if(!companies || companies.length==0)
    Without the last part, the next run will have "[]" as companies and the if statement will be false as an empty array is set and is not null.

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

      Yes, this is a valid point. The script could be improved, the concept is largely the same.

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

      Even if you set in the pre-request script : if(!companies || companies.length==0), array = [] still and the error still occurs

  • @simplearora1223
    @simplearora1223 3 года назад +1

    Hello Valentine, I tried almost the same thing i.e passing an array of values to an api and when i executed the same API i got a message "There are no test for this request". Why am i getting this message?

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

      As the error says, you probably did not write any tests for the request.

    • @simplearora1223
      @simplearora1223 3 года назад

      @@vdespa I have written the same code as that of yours.I was passing a wrong variable name and hence was getting this message. Strange though.It works now. Thanks for your response.

    • @pearlking
      @pearlking 3 года назад

      @@vdespa For me also it showed the same message but the multiple post operation also worked as expected.

  • @merajulhaque9107
    @merajulhaque9107 4 года назад

    postman.setNextRequest("xyz") throwing BAD Request 400, please suggest

  • @jlwasmer
    @jlwasmer 5 лет назад +1

    Skip to 2:45

  • @Fernandomoraissilva
    @Fernandomoraissilva 3 года назад

    Fiz a mesma coisa e não funcionou nada..

  • @akashkapoor3866
    @akashkapoor3866 4 года назад

    Getting error Cannot read property 'get' of undefined

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

      Which Postman version are you using?

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

    How do I login to a page with different usernames and passwords

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

      Maybe Postman is not the best tool for the job.

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

      @@vdespa If I am to try the above on Postman, is there a way ?

  • @DrFearrr
    @DrFearrr 4 года назад +2

    This can be done much simpler.
    Just add csv file as Data in Postman Collection Runner. The csv should contain only one column - "company" with all the values
    And there you go. No pre or test scripts are needed.

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

      Sure. This example is useful if you don't know the data in advance. For example if it comes from the response of a previous request.

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

    My api is running only 1 time

  • @nithyaraji7694
    @nithyaraji7694 5 лет назад

    Great video, Thanks!
    I've my tests and pre-requisite scripts, after i go to Runner, select the collection and I let the Iterations=1 and the test just run only one time. If i change the iterations to 3 then the first value from the array is only getting executed 3 times, none of the other values are getting picked up. Please advise.
    *My Prerequisite script : *
    var states = pm.environment.get("states");
    if (!states){
    var states = ["TX", "GU", "AK"];
    }
    var currentState = states.shift();
    pm.environment.set("stateUS", currentState);
    pm.environment.set("states", states);
    *My Test : *
    var states = pm.environment.get("states");
    if (states && states.length > 0) {
    postman.setNextRequest("My request url");
    console.log("Executed");
    }
    else
    {
    postman.setNextRequest(null);
    }
    Note: the values from "states" variable should be sequentially entered in one of the headers and response will be validated in the Tests.

    • @nuriagonzalez7674
      @nuriagonzalez7674 4 года назад

      I have the same problem. 1 iteration--> only one test but my array have 3 elements

    • @archanashinde8029
      @archanashinde8029 4 года назад

      same with me I have 3 elements in array , but while executed only one is executed

    • @patrykjanka
      @patrykjanka 4 года назад +1

      @@archanashinde8029 Try this: find the name of your request (it is highlighted in Collections list (after POST) then in Tests under "if" put postman.setNextRequest("NAME_OF_YOUR_REQUEST");

    • @marianamontenegro77
      @marianamontenegro77 4 года назад

      @@patrykjanka I have the same problem. I put the name of the request but it didn't work

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

      @@patrykjanka This worked for me! Thank you!

  • @zienunyei1614
    @zienunyei1614 5 лет назад

    Hello, I have done the steps in this example but it only seems to be sending one company at a time. It doesn't loop until it becomes invalid. Am i doing something wrong?
    **PRE-REQUEST SCRIPT**
    var companies = pm.environment.get("companies");
    if (!companies) {
    companies = ["Goooooooooogle", "Yahoo!", "Facebook", "Amazon", "Currys", "Orion", "Zienu"];
    }
    var currentCompany = companies.shift();
    pm.environment.set("company", currentCompany);
    pm.environment.set("companies", companies);
    **TESTS**
    var companies = pm.environment.get("companies");
    if (companies && companies.length >0){
    pm.sendRequest("postb.in/5HXHKNhQ", function (err, response) {
    console.log(response.json);
    });
    }
    else {
    pm.sendRequest(null);
    }

    • @zienunyei1614
      @zienunyei1614 5 лет назад

      @@vdespa the postman.setNextRequest didn't work for me

    • @akashkapoor3866
      @akashkapoor3866 4 года назад

      I'm getting error - Cannot read property 'get' of undefined. Please help

    • @Danish-797
      @Danish-797 4 года назад

      Same issue with me, Only one company from array is getting picked and run, it doesn't run for other.

    • @nuriagonzalez7674
      @nuriagonzalez7674 4 года назад +1

      @@Danish-797 I have same error, Does somebody know why?

    • @archanashinde8029
      @archanashinde8029 4 года назад

      same foe me it works for only one element from array. Please reply with solution

  • @federicovalerin1444
    @federicovalerin1444 5 лет назад

    Pretty unnatural for a tool used by hundreds of companies and thousands of developers. And pretty industrious. What if you have 100 urls to automate, not 100 but 50, what if you have 100 values for one url, you will have to create an array with 100 values, pretty uncomfortable too. This is one of those features that could be so naturally embedded on the app, but for some reason is not, like Microsoft they just decide that something that should be so easy must be difficult and time consuming.

  • @alinalipova6974
    @alinalipova6974 3 года назад

    Hi, Valentin! Can you help me pls, what if in "companies" instead of array ["name1", "name2"] i would like to get Environment Variable with array of numbers (in my case) that looks like [1,2,3] and i want my requests to loop through this array, if i simply put in "companies" : pm.environment.get("my variable"); all i get is all array in my request body parametr

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

      Sorry for the late reply. Are you still facing this problem? Maybe you can join Discord and ask there.