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: 
Ziedkh
Contributor III
Contributor III

How to upload PDF file (1) and other parameters (2) through POST REST API

Hello community,

I would like to create a REST request with the following parameters int Talend. Which component should I use and how to pass parameters to this component (body)? I have all necessary metadata on an input edge, need to transform somehow to body/string parameter and add definition for file to upload (path on the edge).

0695b00000L1mZ5AAJ.png 

I have used tRestClient :

0695b00000L1maXAAR.png 

0695b00000L1mbfAAB.png 

0695b00000L1mbuAAB.png 

and I used tRest :

0695b00000L1mdHAAR.png 

0695b00000L1mdRAAR.png 

Any Help please

@

xdshi

@richard Hall​ 

Thank you.

Labels (3)
1 Solution

Accepted Solutions
Ziedkh
Contributor III
Contributor III
Author

Hello @Richard Hall​  @Xiaodi Shi​ 

 

I have finally make this API.

I have used tFileFetch :

0695b00000LxFpVAAV.png0695b00000LxFpzAAF.pngHere is my notes to close this case :

  • In TFileFetch, we didn’t specify the context-type ( it’s already specified in the component code )
  • We get the responses ( sucess or reject ) from global variables ERROR_MESSAGE and INPUT_STREAM )
  • We get responses with OnComponentOk and OnComponentError
  • We have to put an iterate link before tFileFetch to eliminte loops generated on errors

 

Thank you for your collaboration.

 

zied

View solution in original post

19 Replies
Anonymous
Not applicable

Hello,

Could you please stick to one topic:

https://community.talend.com/s/question/0D55b00006e5eJ3CAI/api-rest-post-pdf-file-with-other-params so that we could pay individual attention to your issue. Thanks for your time.

Bets regards

Sabrina

Anonymous
Not applicable

Hi @zied khayechi​,

 

Unfortunately it is very difficult to help with web service queries like this as they all have their own requirements. One solution certainly doesn't fit all when it comes to services.

 

However, I have spotted a few issues in your config that might be causing this.

 

First of all, in your tRestClient config, you are not setting the "Accept Type" to Multipart. This needs to be done when transferring files.

 

Also, when you are using the FORM Content Type, the query params box below becomes the place to configure your form params. So all of your params shown in the top image need to be in there and named appropriately.

 

WIth regard to the file name, you may need to play around with this a bit. It won't just be the name you need to supply, I suspect that it will need to be the full path to the file.

 

Can you try this out and let us know how you get on?

Ziedkh
Contributor III
Contributor III
Author

Hello @Richard Hall​ 

 

i have already test it, but it didn't work for me 😞

 

 

0695b00000L1yUCAAZ.png0695b00000L1yW3AAJ.png 

 

Anonymous
Not applicable

Can you post the error message please? The NullPointerException should not be happening.

 

Also, what is being sent via the tJava4. The tJava is not meant to be used like that. It would be better to use the tJavaFlex to send row data. Can you share the code and show your tRestClient input schema?

Ziedkh
Contributor III
Contributor III
Author

In fact, i wanna just post a pdf file and queries via API .

and I don't have anything as input ( BODY/STRING) ( as we have multipart/form-data content-type)

0695b00000L26G8AAJ.png 

0695b00000L26GIAAZ.pngwhen i put accepter-type = multipart I got a NullPointerException

0695b00000L26H6AAJ.pngBut as accepter type = all , I got Bad request ( missing queries )

 

|400   |{"code":400,"success":false,"data":{"error":"Bad request - repository_id is missing or null"}}|

 

This is the API Swagger:

0695b00000L26GXAAZ.png 

Thanks @Richard Hall​ 

Anonymous
Not applicable

Can you try moving the repository_id from params to the header section. It looks like you have it as a header variables in your tRest that is working. However in your tRestClient version you have it as a param.

Ziedkh
Contributor III
Contributor III
Author

does't work either 😞 0695b00000L273tAAB.png0695b00000L273yAAB.png

Anonymous
Not applicable

Can you share the API documentation? It is almost impossible to guess at what an API requires I'm afraid.

Ziedkh
Contributor III
Contributor III
Author

here the API DOc

0695b00000L2HeQAAV.png