Ask a Question

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

SOLVED
CamillaR
Occasional Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions
CamillaR
Occasional Contributor

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

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

View solution in original post

6 REPLIES 6
nmrao
Community Hero

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

@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)



Regards,
Rao.
nmrao
Community Hero

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

I would also suggest to look at how the token is generated and is it setting value into custom property as well.


Regards,
Rao.
richie
Community Hero

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

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
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
CamillaR
Occasional Contributor

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

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

View solution in original post

nmrao
Community Hero

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

Glad you isolated the issue and resolved.

Many generate the token within the tool itself, so you don't have to use multiple tools.
Is it JWT token or OAuth?


Regards,
Rao.
CamillaR
Occasional Contributor

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

Aha, I would love to do that too!

It's OAuth.

cancel
Showing results for 
Search instead for 
Did you mean: