Ask a Question

How to download a file from ReadyAPi using groovy script

SOLVED
doubtsreadyapi
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.

19 REPLIES 19
nmrao
Champion Level 3

Can you not use HTTP Request?


Regards,
Rao.

Hi @nmrao 

 

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

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.

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

Can you please try and see?


Regards,
Rao.

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

 

 

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.

Hi @nmrao 

 

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

doubtsreadyapi_0-1590728185116.png

 

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


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: