Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I need to post a picture (.jpg file) using an api with Talend.
Thank you very much for your help.
Best regards
Hi, use tRestclient with bear token auth , you have to look a the documentation of your api to see example of what you want.
Send me Love and Kudos
Hi
Thanks for your help.
The documentation :
SetPictureUser
Body: (Form-data)
- UPN : Identifier is UserPrincipalName, equivalent to email
- Image (IFormFile of image 400x400)
Returns: ResultInfo Item
ResultInfo item
· IsSuccess (Boolean)
· Message (Text)
I used this below but if i look the code i have the error on this :
webClient_tRESTClient_3.query("Image" ,"C:\Users\c_acccma\300000052847554_400.jpg");
Thanks
I replaced the path "C:\Users\c_acccma\300000052847554_400.jpg"
by
"C:/Users/c_acccma/300000052847554_400.jpg"
It's better but now i have the error :
mai 26, 2021 2:55:13 PM org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFOS: Creating Service {http://www.talend.org/esb/sam/MonitoringService/v1}MonitoringServiceService from class org.talend.esb.sam.monitoringservice.v1.MonitoringService
mai 26, 2021 2:55:15 PM org.apache.cxf.ws.addressing.ContextUtils retrieveMAPs
AVERTISSEMENT: WS-Addressing - failed to retrieve Message Addressing Properties from context
mai 26, 2021 2:55:15 PM org.talend.esb.sam.agent.collector.EventCollector sendEvents
INFOS: Put events(1) to Monitoring Server.
Exception in component tRESTClient_3 (PostPicture)
javax.ws.rs.WebApplicationException: HTTP 400 Bad Request
at prj_mch.postpicture_0_1.PostPicture.tRESTClient_3Process(PostPicture.java:1749)
at prj_mch.postpicture_0_1.PostPicture.runJobInTOS(PostPicture.java:5087)
at prj_mch.postpicture_0_1.PostPicture.main(PostPicture.java:4779)
In fact in Postman i select the file and the type of the field "Image" is a file. But with Talend i indicate the path. So maybe the problem is here.
I don't know how to do this because i have to send 2 fields : an email and the .jpg file. In Postman i can see "form-data" in the body. But how to do this in Talend ?
Thanks for your help.
Does your request work on postman ? you can try to add the header parameter you have in postman in your trestclient.
The request works on Postman.
I added the same header except Authorization, Postman-Token and User-Agent.
Talend :
Postman :But i have the error :
don't use those who have the value calculated when request is sent
for content-type keep multipart but throw the boundary part)
if you sned data via body you have to set one to send to the trestclient