Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Swiip
Contributor
Contributor

How to post a picture with an API (authorization : Bearer token)

Hi

I need to post a picture (.jpg file) using an api with Talend.

  • Maybe i have to use a tRESTClient with the method POST. But if i use this component how to indicate the file to upload ?
  • Maybe i have to use a tFileFetch with the method POST. But if i use this component i can check the box for the authentification (in advanced parameter) but i can see only User and Password. But i have to use a bearer token. How to use the token ?

Thank you very much for your help.

Best regards

Labels (3)
22 Replies
gjeremy1617088143

after few schearch , it seems tfilefetch can upload file , maybe it's a better solution than trestclient

Swiip
Contributor
Contributor
Author

But with tFileFetch we haven't the option to use a token.

In the advanced parameters i can see only authentification with user and password.

gjeremy1617088143

add it on the header : key: Authorization value: Bearer (your bear token)

you can see it on the postman header of your request

Swiip
Contributor
Contributor
Author

With the tRESTClient i deleted those who have the value calculated when request is sent. And now i have the error HTTP 302 found.

 

Ok i will try with the tFileFetch.

Swiip
Contributor
Contributor
Author

I tried with the tFileFetch but i have a 302 error.

0695b00000F98eCAAR.png0695b00000F98eHAAR.png0695b00000F98eWAAR.png

gjeremy1617088143

check the checkbox : Supporter la redirection

Swiip
Contributor
Contributor
Author

I checked the box "Supporter la redirection"

 

The picture is not uploaded and i have this message :

Starting job PostPicture at 17:04 27/05/2021.

[statistics] connecting to socket on port 3730

[statistics] connected

mai 27, 2021 5:04:59 PM org.apache.commons.httpclient.HttpMethodBase processResponseHeaders

AVERTISSEMENT: Cookie rejected: "$Version=0; .AspNetCore.Correlation.WsFederation.TJA834Kl8XKQzyAn0QTbmFdU17466oVHhAKXW0L0nTc=N; $Path=/signin-wsfed". Illegal path attribute "/signin-wsfed". Path of origin: "/sync/SetPictureUser"

mai 27, 2021 5:04:59 PM org.apache.commons.httpclient.HttpMethodDirector isRedirectNeeded

INFOS: Redirect requested but followRedirects is disabled

Redirect to: https://fed.plop.com/adfs/ls/?wtrealm=https%3A%2F%2Fpreprod-monprofil.plop.com&wa=wsignin1.0&wreply=https%3A%2F%2Fpreprod-monprofil.plop.com%2Fsignin-wsfed&wctx=CfDJ8Lk1mSvqXe1BhWaRY4j4lNrJQSydG_-17YRh2vqMQg_6bXUgHzgpzLCKxqUUZDmZMLJ-Th1IefDDJueqspumCx903pdj0iaa-AOeM_LBYIj3FLHgREDZEChkvnP-eswDmHgCwF2bJ6rSnXtNUf6rYnth_OIl8ztdk9KY3mbVPbjmCzZ7kprXaDGf4jEe3InDtUeFpbNR_IbBR8elI56H4BYz2G34QtxUNZ-4hcPXBPco9i18BHOCnO5MayOl2lJWRq0wttUeg-UIQqBfVqK3uSM

[statistics] disconnected

 

Job PostPicture ended at 17:04 27/05/2021. [exit code = 0]

 

Swiip
Contributor
Contributor
Author

I am always blocked on this topic.

Swiip
Contributor
Contributor
Author

I saw this post https://community.talend.com/s/question/0D53p00007vCqSWCA0/passing-multipart-form-data-in-talend

So i think it's possible with tRestClient.

I tried again and i have the message :

"Exception in component tRESTClient_3 (PostPicture)

javax.ws.rs.WebApplicationException: HTTP 302 Found

at prj_mch.postpicture_0_1.PostPicture.tRESTClient_3Process(PostPicture.java:1748)

at prj_mch.postpicture_0_1.PostPicture.runJobInTOS(PostPicture.java:5086)

at prj_mch.postpicture_0_1.PostPicture.main(PostPicture.java:4778)"

 

Swiip
Contributor
Contributor
Author

In fact i think i have 2 problems.

1) Problem of access (HTTP 302 found)

2) In the parameter "Image" of the API i put the path of the file but we need to put directly the file.

 

Someone can help me to find how to put a file in a parameter of an api with Talend ? and not just the path of the file. So for the point 2)

 

Thanks