Forum Discussion

CamillaR's avatar
CamillaR
Occasional Contributor
3 years ago
Solved

How can I use a property in the header for a request in ReadyAPI

Hi,

 

I have a SoapUI project where I use a project property "token" that is used in the header of the requests, I reference it as ${#Project#token}, 
see attachment for more details. I do this since I have many requests and the token needs to be renewed every hour. I load the token value into the property using a groovy script test step. This works fine when I run my requests using SoapUI 5.6.0.

 

Now I have installed ReadyAPI 3.1.0 and imported my SoapUI project. When I run my requests in ReadyAPI I get error 503 Service Unavailable. It works OK if I use the real value in the header, e.g "Bearer eyJ0eXAiOiJKV...." but not when I use ${#Project#token} in the header.

Why does it work in SoapUI but not in ReadyAPI?

And how can I use the project property in the header? 

 

Kind Regards,

Camilla

  • Hi nmrao,

     

    You were on to something here. The problem was in my token.

    1. I run a curl command in bash to generate the token and save the result to a textfile. This is done by adding " > c:/mytokenfile.txt" after the curl command

    2. In SoapUI/ReadyAPI, my groovy script reads the textfile and stores the contents in the project property.

     

    The problem was this: When storing the token value into a textfile cr+lf is added at the end. And this was also read into the property.

    When viewing property value the cr+lf looks like a blank space in the end (in the property window). 

    I have now fixed my groovyscript so it does not store the cr+lf in the property.

     

    Thanks for the help,

    /Camilla

6 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    CamillaR 

     

    It must work in ReadyAPI as well. You may raise a ticket with Smartbear customer service.

     

    Before that you may want to check on the latest available release of ReadyAPI (if you can)

    • nmrao's avatar
      nmrao
      Champion Level 3
      I would also suggest to look at how the token is generated and is it setting value into custom property as well.
      • richie's avatar
        richie
        Community Hero
        Hey CamillaR,

        I dont think this is an issue with ReadyAPI as i was doing what youre doing with v3.1.0.

        Have you tried comparing the exact RAW details from what youre generating in soapui relative to ReadyAPI? thats how id work out whats going wrong.

        Have you definitely got percent encoding set in both?

        Ta

        Rich