cancel
Showing results for 
Search instead for 
Did you mean: 

save image from api response to file groovy

Highlighted
New Contributor

save image from api response to file groovy

hi,

i am new to groovy and my requirement is to save API response to image file  with groovy script.

i checked with previous thread but it's not working.

Can somebody please share groovy code with required import groovy classes.

it will be very helpful,

thanks in advance.

5 REPLIES 5
Highlighted
Community Hero

Re: save image from api response to file groovy

Hey @erarunmishra9

According to the help you dont need to rely on groovy for this.
Is this for a REST step or SOAP request?
As long as this is REST, according to the help you can use the 'Dump file' atteibute within your request attributes to save a requests response including any associated file attachments.

Cheers,

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
Highlighted
New Contributor

Re: save image from api response to file groovy

hi Richie,

this is a REST response and i have to this in groovy.

Highlighted
New Contributor

Re: save image from api response to file groovy

is it feasible in groovy to save REST API image response in .jpg/.png file?

if yes please suggest additional classes also.

Highlighted
Community Hero

Re: save image from api response to file groovy

Hey @erarunmishra9,

The Dump File attribute saves REST response files, not SOAP so you could use this.
This raises the question, why bother with groovy when the native functionality does it for you? (the DumpFile property works for REST requests)
Theres just no added value. The expert groovy coders on the forum (which im not one of them) typically only extend their tests using groovy when the functionality doesnt do what is needed.

For example. You can build up an actual REST request along with the various header, uri/template and query parameters by using groovy alone, but theres no point when you have a REST test step that does it for you.

Can you clarify why you cant use the native functionality? (The Dump File property).

Could you please provide the RAW tab details (headers and payload) of your response?

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
Highlighted
New Member

Re: save image from api response to file groovy

Hello buddy..

 

Thanks for sharing.Finally i have known what i want.

Ghdsports Apk

Tags (1)
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors