cancel
Showing results for 
Search instead for 
Did you mean: 

How to download a file from ReadyAPi using groovy script

SOLVED
Highlighted
Contributor

How to download a file from ReadyAPi using groovy script

Hi 

 

Is there a way from Ready APi to download a file using groovy script, and place it in my local directory?

ie., when i hit a URL the excel file download automatically when it get downloads it must  get stored into my local directory path. and to download the file authorization is required, so how to pass the authorization?

 

Thanks in Advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: How to download a file from ReadyAPi using groovy script

Was there any issue to just follow what was mentioned in the earlier reply?
Isn't url forming incorrect by just looking at it?

http://( '${#TestCase#TEST URL}' ) -> change it to ${#TestCase#TEST URL}


Regards,
Rao.

View solution in original post

19 REPLIES 19
Highlighted
Community Hero

Re: How to download a file from ReadyAPi using groovy script

Can you not use HTTP Request?


Regards,
Rao.
Highlighted
Contributor

Re: How to download a file from ReadyAPi using groovy script

Hi @nmrao 

 

Thanks, The url changes every time. so using HTTP request can we acheive? 

Community Hero

Re: How to download a file from ReadyAPi using groovy script

Use property expansion for url of the HTTP Request.
That means, the value for the URL has to be assigned in the previous test step
Say use a test case level custom property FILE_DOWNLOAD_URL and assign the value for before executing HTTP Request.
In the URL for HTTP Request, assign value "${#TestCase#FILE_DOWNLOAD_URL}"

Here is the documentation for Property expansion
https://www.soapui.org/scripting-properties/property-expansion/


Regards,
Rao.
Highlighted
Contributor

Re: How to download a file from ReadyAPi using groovy script

Hi @nmrao 

 

Thanks once again, You mean to say in the HTTP Request, in End Point field i have to pass like this "${#TestCase#FILE_DOWNLOAD_URL}"? and where will the file will get stored?

 

Please let me know my understanding is correct

Highlighted
Community Hero

Re: How to download a file from ReadyAPi using groovy script

Can you please try and see?


Regards,
Rao.
Highlighted
Contributor

Re: How to download a file from ReadyAPi using groovy script

@nmrao 

 

I tried but its not working, as mentioned i kept http://( '${#TestCase#TEST URL}' )  in the Request URL

 

my sample url looks like below:

https//testsample.com//testingurl_f21ae8be36da/fa3f1ff5-93e1-4468-bf43-6541c317b6e8'%20

 

below is the error i am getting

2020-05-28 23:14:30.087 - Error getting response; java.net.URISyntaxException: Illegal character in authority at index 7: http://( 'https//testsample.com//testingurl_f21ae8be36da/fa3f1ff5-93e1-4468-bf43-6541c317b6e8'%20)

 

When i tried giving the url in the request url i am getting below error

 

{
"message" : "You must specify only one folder in the url for POST requests."
}

 

So please let me know how to achieve this.

 

 

Highlighted
Community Hero

Re: How to download a file from ReadyAPi using groovy script

Was there any issue to just follow what was mentioned in the earlier reply?
Isn't url forming incorrect by just looking at it?

http://( '${#TestCase#TEST URL}' ) -> change it to ${#TestCase#TEST URL}


Regards,
Rao.

View solution in original post

Highlighted
Contributor

Re: How to download a file from ReadyAPi using groovy script

Hi @nmrao 

 

I tried by giving  ${#TestCase#TEST URL} , i am getting below endpoint error,  

doubtsreadyapi_0-1590728185116.png

 

Highlighted
Community Hero

Re: How to download a file from ReadyAPi using groovy script

Hope you have assigned the value for the custom property. Haven't you?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors