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: 
Anonymous
Not applicable

Https File Upload with Multipart/Form-Data

I'm working on an integration and need to upload files to an API.  The API documentation says to " Send your file to 
POST /pendingfiles.json

 using the FORM field 
file

"
I tried using tRestClient, but when you select FORM, it sets the content-type as "application/x-www-form-urlencoded".  The API doesn't accept that; it has to be multipart/form-data.
I tried using tFileFetch and set the Upload File parameter to True and passed in teh File parameters Name = "file", File = filePath, etc.  This actually worked, but I got an error because  the response from the API was a 201: Created.  Apparently, tFileFetch only considers a 200: OK as an acceptable response.
I tried following this post that suggests customizing tRestClient so that it will accept a multipart form, but I couldn't get the parameter named correctly (form field has to be file) to make it work.   https://community.talend.com/t5/Design-and-Development/tRestClient-MIME-Multipart-Form-Data-POST-to-...
This post explained the problem that tFileFetch only allows a 200 OK response.  https://community.talend.com/t5/Design-and-Development/resolved-Upload-file-to-server-that-returns-o...
After the last post, I created a new version of tFileFetch and adjusted the accepted responses to 200 OK and 201 Created.  It successfully posted the file and gave a correct response.  
But now, I need to be able to parse the response to get the file token.  When the file successfully uploads, I get a temporary file token that I can then use to attach it to another object in the system.  So I have to be able to parse the response to get that file, otherwise it's no good to me.
So I either need to figure out how to adjust tFileFetch so that the response can be sent out as a row or I need to find another way of uploading the file.
I'm not a developer and only understand the basics in Java programming. Any suggestions or help would be greatly appreciated.
Labels (5)
1 Reply
Anonymous
Not applicable
Author

Unfortunately it is not supported directly in tRESTClient,
please vote for
https://jira.talendforge.org/browse/TESB-12065
I guess in meantime any HTTP client that can post multipart payloads can be used in tJavaFlex, Apache HTTPClient or CXF, I can prototype the code for the latter option if it can be of interest

Sergey