Forum Discussion

mrarkapravo's avatar
mrarkapravo
Contributor
4 years ago
Solved

how delete multiple generated ids one by one using delete endpoint

I am creating 5 records using Post end points, then after creating those ids I want to delete them one by one using delete end point just for clean up , so how can I achieve it?

 

So here, I cannot delete multiple IDs in a single request.

 

While creating the records, storing them in a property as object as below-

{"id1":"124","id2":"234","id3":"345" }

 

Tried it with groovy, where I am reading those IDs from the property using "Data Source" and then trying to use them for delete using loop, but problem is the loop is going infinitive and for delete always taking only 1st ID i.e "id1":"124".

It would be great if anyone can give me solution .

 

  • Hi scot1967 ,

     

    If you are looking for a code here is the example

     

     TempArray["Test"] = BuiltIn.CreateVariantArray(0, 5);

      var i;

      for(i = BuiltIn.VarArrayLowBound(TempArray["Test"] , 1); i <= BuiltIn.VarArrayHighBound(TempArray["Test"] , 1); i++)
    {
         Log.Message(TempArray["Test"] (i) );
    }

     

    -Ashwin

    Please give a Kudo and accept it as a solution if this works

19 Replies

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3

    Can we see the code please?  This high level doesn't really help us help you.

    • Xman1's avatar
      Xman1
      Occasional Contributor

      Heres my code for the login

  • Xman1's avatar
    Xman1
    Occasional Contributor

    I have considered just making another keyword test, and doing the loop there, but whenever I make a data loop, I cannot have the table as an input for the login because its a keyword test.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      OK... what I would do is this:

       

      1) Step one in your data driven loop is to set a project level variable to equal the URL that you get from the loop data.

      2) Then, in your different keyword tests, whenever you need to reference the URL, use that project level variable.

      • Xman1's avatar
        Xman1
        Occasional Contributor

        Do I do all of this within a keyword test or withing the suite?