Forum Discussion

jly's avatar
jly
Occasional Contributor
3 years ago

HELP - Trouble passing values from one API to next API

I am having trouble passing values between from one API to next API for some routes.  And I'm not sure why.

 

I have CreateCustomer route and then in GetCustomer route I get the id from the CreateCustomer route (1).  

I used the GetData functionality to retrieve the value ${#[MEC-Shakedown#/api/v1/customer: CreateCustomer#POST Request]#Response#$['data']['id']}

That works ok, I can see the id in the raw format (ie GET http://mec-stage-proc:9031/api/v1/customer/57863 (2))

And I was returned a response  (3), see screenshot directly below: 

 

But when I try the same thing for my PauseContract API - first I cannot see the expected value (1) in raw format and then I don't get a response (2).

So in PauseContract API, I obtain the contractId from the response from GetContractAPI

${#[MEC-Shakedown#/api/v1/customer/{id}: GetCustomer#GET Request]#Response#$['data']['contracts'][0]['contractId']}

The raw format is POST http://mec-stage-proc:9031/, but I am expecting GET http://mec-stage-proc:9031/api/v1/contract/55/pause, as a result I am not receiving a response.  See screenshot immediately below:


What am I doing wrong?

 

I also tried to store the contractId after GetCustomer - and using GetData refer to that property instead.

${#[MEC-Shakedown#/api/v1/customer/{id}: GetCustomer#Properties 2]#contractId}

 

When I hard code the value, I am returned the appropriate response.

 

Yes a newbie to ReadyAPI.

 

Jennifer

 

 

 

 

 

 

  • jly's avatar
    jly
    3 years ago

    Thanks for your time and tips richie.

    Re: I noticed that in your GetCustomer test case you used the PRopertyTransfer object, whereas it appears for the PauseContract test case it looks like you're using the GetData functionality and pulling the values directly from the Properties step.

    Yes I was trying different techniques (ie using GetData and PropertyTransfer) to pass the value to see what would work. 

    Both didn't seem to pick up the value.

    Though the PropertyTransfer did store the value correctly.

     

    The solution seems to be NOT to use special characters (ie curly brackets - {} in this case) as trips over when it's replaced.

    So when I renamed the test case (ie removed {}) - I am about to use GetData functionality to retrieve the value.

    So the value in id of Pause Contract is ${#[MEC-ShakedownForDisplay#GetCustomer#GET Request]#Response#$['data']['contracts'][0]['contractId']}

    (note there is no curly brackets in label for GetCustomer).


    I should have known better - this is standard things to avoid in any language.
    Though note the labels of the test suite and test cases and test steps were created by default when I imported the Swagger definition.  

     

    Jennifer

     

  • richie's avatar
    richie
    Community Hero

    Hey jly 


    You're a newbie? Looks like you're doing ok considering! 🙂

     

    Anyway - you state if you hardcode the values in PauseContract - it works, so this proves you haven't got any low level issues (SSL/HTTPS), or auth considerations getting in the way.

     

    I noticed that in your GetCustomer test case you used the PRopertyTransfer object, whereas it appears for the PauseContract test case it looks like youre using the GetData functionality and pulling the values directly from the Properties step.

     

    When I'm doing stuff like this and I have a problem (i.e. values not being picked up like I expect) I typically try executing the steps one at a time and keep an eye on the ReadyAPI! log and the HTTP log (bottom of the screen).

     

    I notice it's expeditious to not bother with the PropertyTransfer step and use the GetData to pull values directly, however, I've found this doesnt help me when trying to diagnose an issue - especially when stepping through my test steps.

     

    I know some of the other forum users dont bother with PropertyTransfer steps, but I still use them all the time cos it helps when diagnosing a mistake I've made.

     

    Can I suggest adding in a PropertyTransfer step between the Properties step and the Post Request step in the PauseContract test, then execute the steps one by one? (obviously Properties step isn't executable, so start from the PropertyTransfer)

     

    Cheers,

     

    Rich

    • jly's avatar
      jly
      Occasional Contributor

      Thanks for your time and tips richie.

      Re: I noticed that in your GetCustomer test case you used the PRopertyTransfer object, whereas it appears for the PauseContract test case it looks like you're using the GetData functionality and pulling the values directly from the Properties step.

      Yes I was trying different techniques (ie using GetData and PropertyTransfer) to pass the value to see what would work. 

      Both didn't seem to pick up the value.

      Though the PropertyTransfer did store the value correctly.

       

      The solution seems to be NOT to use special characters (ie curly brackets - {} in this case) as trips over when it's replaced.

      So when I renamed the test case (ie removed {}) - I am about to use GetData functionality to retrieve the value.

      So the value in id of Pause Contract is ${#[MEC-ShakedownForDisplay#GetCustomer#GET Request]#Response#$['data']['contracts'][0]['contractId']}

      (note there is no curly brackets in label for GetCustomer).


      I should have known better - this is standard things to avoid in any language.
      Though note the labels of the test suite and test cases and test steps were created by default when I imported the Swagger definition.  

       

      Jennifer