Forum Discussion

nkpalli's avatar
nkpalli
Contributor
7 years ago
Solved

how to pass Valid and Invalid value to resource endpoint parameter

 

Hello team,

 

 Need some clarification on how to achieve this scenario:  I have a endpoint and i am trying to acheive two tests by passing valid and Invalid values to ID Parameter that exist in resource URL 

 

1) Check API runs successfully when Valid ID is passed

2)Check API response when Invalid ID gets passed 

 

Endpoint   :https://TestURL/${#Project#ID}/newpricing/${#Project#pcode}/units?pdate=${#Project#PDate}

 

Resource URL:${#Project#ID}/newpricing/${#Project#pcode}/units

Parameters :${#Project#PDate}

 

 

 Added REST test step and select rest method to invoke the request based off this resource om first test case which passes valid ID value set at property level  (https://TestURL/${#Project#ID}/newpricing/${#Project#pcode}/units?pdate=${#Project#PDate})  

 

Added Another REST test step and select same rest method to invoke the request based off the first resource  but i need to pass Invalid ID value in this case : How do we acheive this ? Looks like i was only able to acheive this by creating  new resource method which has InvalidID in resource URI ..something like this https://TestURL/${#Project#InvalidID}/newpricing/${#Project#pcode}/units?pdate=${#Project#PDate})  

 

 

  • You want your Resource to give just what the parameters are, not the values for them.

     

    /{projectId}/newpricing/{pcode}/units

    Then in the Test Requests themselves, you set:

     

    projectId = ${Project#ID}

    or

     

    projectId = ${Project#InvalidID}

5 Replies

  • Any suggestions. I am using soapUI free version so wondering if there is another way to accomplish this where we can pass valid and invalid data at test case level to the same resource end point 

     

  • JHunt's avatar
    JHunt
    Community Hero

    Yes, this is a typical thing to do. See attached picture for how to structure it.

    • nkpalli's avatar
      nkpalli
      Contributor

      Thank you for sharing structure  and i gave this approach a try! .... but looks like i  am not able to change the resource URL in the rest test step  level .How did you change the resource URL in these  below test steps as i am unable to edit that section ?

       

      For Valid Project ID i see the resource URL is : ${#Project#somevalidproject ID}/newpricing/

      and for invalid Project ID is see the resource URL says : : ${#Project#Invalidproject ID}/newpricing

       

      Rest method invoke for request when the test step created looks like this :https://endpointURL/${#Project#project ID}/newpricing/

  • JHunt's avatar
    JHunt
    Community Hero

    You want your Resource to give just what the parameters are, not the values for them.

     

    /{projectId}/newpricing/{pcode}/units

    Then in the Test Requests themselves, you set:

     

    projectId = ${Project#ID}

    or

     

    projectId = ${Project#InvalidID}
    • nkpalli's avatar
      nkpalli
      Contributor

      Thank you for your time and help clarify issue .