Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I use the tRestClient component to execute a GET on an API to get a picture in the answer.
I tried with Postman and i got a binary file with the extension ".bin".
If i rename this file with the extension ".jpg" i can see the picture.
But in Talend with tRestClient i can't generate the correct picture.
I tried to do this :
tRestClient => tmap => tFileOutputRaw
In the tmap i choose only the string (and not statusCode and body). In the tFileOutputRaw i generated a file. But it's not a picture. The size of this file is 24 ko. And with my test on Postman the size of the file is 25 ko. If i rename the file generated with the extension ".jpg" it isn't a picture.
Thank you very much for your help.
Have a good day
Sorry i don't know if i am clear.
The first file = file generated by Talend
The second file = file generated by Postman
I suspect an encoding problem .
you can do two things. Check the header generated by postman for encoding and set them on the tRestClient And after force the Jvm default charset for encoding
If i run the api with Postman i can see in Headers :
Accept-Encoding = gzip, deflate, br
Content-Encoding = gzip
So i added Content-Encoding = gzip in the parameter of the tRestClient but i have an error 400 :
You have to put them in advanced settings view of the component , HTTP headers. and put this :
key : "Content-Type"
value : "text/html; charset=iso-8859-1"
it will force the encoding of the response.
The result is the same a file of 44ko
In Postman i saw Content-Type=application/octet-stream
So i tried this in the HTTP header of tRestClient but same result a file of 44ko
maybe "application/octet-stream; charset=binary"
or "application/octet-stream; charset=iso-8859-1"
and you can put -Dfile.encoding=ISO-8859-1 in your jvm parameter
cause you have difference in file size explain by bad encoding, by the parameters give in the response or by Talend (by default Talend use UTF-8 in te JVM.
Same result a file of 44ko :
I tried "application/octet-stream; charset=binary" => file of 44 ko not correct
I tried "application/octet-stream; charset=iso-8859-1" => file of 44 ko not correct
I tried -Dfile.encoding=ISO-8859-1 in your jvm parameter => file of 24 ko not correct
The correct size is 25 ko.
I renamed the extension of the postman response in .txt and i renamed also the extension of the file generated by talend in .txt.
After this i compared the 2 files with the tool Winmerge.
Below at the left the file of 44 ko generated by Talend and at the right the file generated by Postman.
At the bottom of the screen of Winmerge we can can see UTF-8 at the left and Windows 12-52 at the right