Forum Discussion

PM's avatar
PM
Contributor
7 years ago

PUT/DELETE - Unable to call output of Get operation parameter values in the payload (Delete Body)

First used GET Method:-

 

{"GetCustomerPartNumbersResp": {"CustomerPartNumberRelationshipCollection": {"CustomerPartNumberRelationship": [{
"ProductNumber": "100074",
"CustomerPartNumber": "TEST"
}]}}}

 

Expected - Want use the same out of GET operation in the Request Body of DELETE Method.

Tried below code in the Request Pay Load Body of the DELETE but it give an error that is too long Prod Number and Part Number. 

 

{
"DeleteCustomerPartNumbersReq": {
"ProductNumber": "$['GetCustomerPartNumbersResp']['CustomerPartNumberRelationshipCollection']['CustomerPartNumberRelationship'][0]['ProductNumber']",
"CustomerPartNumber": "$['GetCustomerPartNumbersResp']['CustomerPartNumberRelationshipCollection']['CustomerPartNumberRelationship'][0]['CustomerPartNumber']"
}
}

 

 

Note: The code is working fine if i get it from Data Source but not from Output of any other operation. 

  • PM's avatar
    PM
    7 years ago

    Thanks for the help but with below code was able to get desired results..

     

    Just required to enter this in the payload:-

    {
    "DeleteCustomerPartNumbersReq": {
    "ProductNumber": "${PUT-GET#Response#$['GetCustomerPartNumbersResp']['CustomerPartNumberRelationshipCollection']['CustomerPartNumberRelationship'][0]['ProductNumber']}",
    "CustomerPartNumber": "${PUT-GET#Response#$['GetCustomerPartNumbersResp']['CustomerPartNumberRelationshipCollection']['CustomerPartNumberRelationship'][0]['CustomerPartNumber']}"
    }
    }

  • nmrao's avatar
    nmrao
    Champion Level 3
    Can you show the sample request for Delete operation request?
      • bagochips's avatar
        bagochips
        Contributor

        add a groovy step to get the values from the first request

        //get values from request
        def ProductNumber = context.expand( '${Get-Delete#script#$[\'GetCustomerPartNumbersResp\'][\'CustomerPartNumberRelationshipCollection\'][\'CustomerPartNumberRelationship\'][0][\'ProductNumber\']}' )
        def CustomerPartNumber = context.expand( '${Get-Delete#script#$[\'GetCustomerPartNumbersResp\'][\'CustomerPartNumberRelationshipCollection\'][\'CustomerPartNumberRelationship\'][0][\'CustomerPartNumber\']}' )

         

        //write to custome property
        testRunner.testCase.setPropertyValue("ProductNumber", ProductNumber )
        testRunner.testCase.setPropertyValue("CustomerPartNumber", CustomerPartNumber )

         

        then in your next service call update your JSON payload


        {
        "DeleteCustomerPartNumbersReq": {
        "ProductNumber": "${#TestCase#ProductNumber}",
        "CustomerPartNumber": "${#TestCase#CustomerPartNumber}"
        }
        }