Forum Discussion

VeenaDevi's avatar
VeenaDevi
Contributor
4 years ago

Handling Request Values (not parameters) in Ready API

Need to pass dynamic values as part of GET request, which is not as a query parameter 

 

for examle 

https://api.loadninja.com/v1/project/0360d710-e091-11eb-b1b1-77ee831bc5f8 /scenarios

 

 

in  this 0360d710-e091-11eb-b1b1-77ee831bc5f8 is dynamic one ... How to pass this values in ready API

 

 

  • Hi VeenaDevi 

     

     

    any changeable value is a parameter of some type - either URI/Template/Resource parm (like the one in your example) or Query parameter or Matrix parameter or Header parms.

     

    The parm you are talking about is the URI/Template/Resource parm (same thing - just different names for it).

     

    I'm doing this on my work laptop (my personal laptop has ReadyAPI! installed) which only has SoapUI installed - so the instructions won't be specific to ReadyAPI! - but you can do the equivalent thing with ReadyAPI! as SoapUI only a lot more easily.

     

    Within the relevant ReadyAPI! project, select 'New REST Service from URI' and input the following into the generated dialogue box 'https://api.loadninja.com/v1/project/{UUID}/scenarios'

     

    This generates a new REST Service in the listing - set the required method on the service and add the required Authentication/Authorization details as well.

     

    Adding the above in essentially generates the new REST Service and the UUID as a RESOURCE level TEMPLATE parameter (Template parms are also known as URI parms or Path parms or Resource parms).

     

    If you look at the screenshot entitled UUIDBefore.png - this is immediately after the new REST Service has been created - you can see the detail of the full URI and the TEMPLATE parm with the value set as 'UUID'

     

    You need to change this - now - there's multiple ways of doing this and when I started using ReadyAPI!/SoapUI, I always included a PropertyTransfer step so there was a visual indication I was transferring a value between one step and another. I think this is advisable (and sometimes I even still do it, just to indicate to anyone else viewing the project a value is transferred), but you dont have to - you can pass values from request's responses to other requests directly - and ReadyAPI! includes a wizard to do this which makes it even easier.

     

    So - I'm going to suggest the easiest option - using the ReadyAPI! wizard.

     

    So - add this new API into your test case (call it 'TestStep2' for now). Add the other test step in the test that generates the required UUID value you mentioned in your post (call it 'TestStep1' for now).

     

    Execute 'TestStep1' in your testcase, so you have the dynamic UUID generated - I'm assuming from the response of 'TestStep1'.

     

    Within 'TestStep2' edit form, you can see the UUID value that needs to be edited. Double click in the 'Value' field to launch ReadyAPI's wizard. Click through the Project >> TestSuite >> TestCase >> to 'TestStep1' and then select the Response option, followed by the UUID that was generated in the TestStep1's response. Accept the changes.

     

    If you now view TestStep2's TEMPLATE parm value details there will be a value in the field that has been auto generated from your previous selection in the wizard - value starts '${TestStep1..'    <-- see attachment UUIDAfter.png for SoapUI equivalent

     

     

    TestStep2 will now always pick up the value generated from whatever value is returned by TestStep1.

     

    cool?

     

    Cheers,

     

    Rich

     

    Rich

  • richie's avatar
    richie
    Community Hero

    Hi VeenaDevi 

     

     

    any changeable value is a parameter of some type - either URI/Template/Resource parm (like the one in your example) or Query parameter or Matrix parameter or Header parms.

     

    The parm you are talking about is the URI/Template/Resource parm (same thing - just different names for it).

     

    I'm doing this on my work laptop (my personal laptop has ReadyAPI! installed) which only has SoapUI installed - so the instructions won't be specific to ReadyAPI! - but you can do the equivalent thing with ReadyAPI! as SoapUI only a lot more easily.

     

    Within the relevant ReadyAPI! project, select 'New REST Service from URI' and input the following into the generated dialogue box 'https://api.loadninja.com/v1/project/{UUID}/scenarios'

     

    This generates a new REST Service in the listing - set the required method on the service and add the required Authentication/Authorization details as well.

     

    Adding the above in essentially generates the new REST Service and the UUID as a RESOURCE level TEMPLATE parameter (Template parms are also known as URI parms or Path parms or Resource parms).

     

    If you look at the screenshot entitled UUIDBefore.png - this is immediately after the new REST Service has been created - you can see the detail of the full URI and the TEMPLATE parm with the value set as 'UUID'

     

    You need to change this - now - there's multiple ways of doing this and when I started using ReadyAPI!/SoapUI, I always included a PropertyTransfer step so there was a visual indication I was transferring a value between one step and another. I think this is advisable (and sometimes I even still do it, just to indicate to anyone else viewing the project a value is transferred), but you dont have to - you can pass values from request's responses to other requests directly - and ReadyAPI! includes a wizard to do this which makes it even easier.

     

    So - I'm going to suggest the easiest option - using the ReadyAPI! wizard.

     

    So - add this new API into your test case (call it 'TestStep2' for now). Add the other test step in the test that generates the required UUID value you mentioned in your post (call it 'TestStep1' for now).

     

    Execute 'TestStep1' in your testcase, so you have the dynamic UUID generated - I'm assuming from the response of 'TestStep1'.

     

    Within 'TestStep2' edit form, you can see the UUID value that needs to be edited. Double click in the 'Value' field to launch ReadyAPI's wizard. Click through the Project >> TestSuite >> TestCase >> to 'TestStep1' and then select the Response option, followed by the UUID that was generated in the TestStep1's response. Accept the changes.

     

    If you now view TestStep2's TEMPLATE parm value details there will be a value in the field that has been auto generated from your previous selection in the wizard - value starts '${TestStep1..'    <-- see attachment UUIDAfter.png for SoapUI equivalent

     

     

    TestStep2 will now always pick up the value generated from whatever value is returned by TestStep1.

     

    cool?

     

    Cheers,

     

    Rich

     

    Rich

    • VeenaDevi's avatar
      VeenaDevi
      Contributor

      Yes , I got it ... Thanks 🙂