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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
bonacq
Contributor
Contributor

API with PDF attach

Hi,

I need to perform a POST call with a PDF file attached.

With Postman it works without any issues using form-data.

bonacq_0-1776177213765.png

The only component that seems suitable for my case in Talend 8.0.1 is tHTTPClient, but I haven’t found the correct configuration.
 
Initially, I tried the most straightforward approach:

bonacq_1-1776177301640.png

and the attachment definition:

bonacq_2-1776177345268.png

but I get: HTTP Query 'http://.../uploadMainDocument' : '400 Bad Request'

Using x-www-form-urlencoded, I add the file path among the body parameters (and remove the attachment), but I get: HTTP Query 'http://.../ws/uploadMainDocument' : '415 Unsupported Media Type'

Has anyone encountered similar situations?

Thanks

Labels (2)
2 Replies
Greg_Taffer
Support
Support

Recommended Configuration for tHTTPClient 
 

According to Talend component documentation, tHTTPClient is the modern replacement for tREST and tFileFetch. Use these settings to match Postman’s behavior:
 

  • HTTP Method: Select POST.
  • Body Type: Select Form data (do not use x-www-form-urlencoded for files as it lacks the proper multipart boundaries).
  • Parameters Table:
    • Add a parameter where the Name matches the key expected by your API (e.g., "file").
    • Set the Value to the absolute path of your PDF file (e.g., "C:/documents/file.pdf").
    • Change the Type for this specific row to File (this is critical for the component to treat the value as a file stream rather than a text string).
  • Headers: Do not manually set the Content-Type header to multipart/form-data. The Postman automated behavior and Talend's internal client both generate the required boundary automatically when "Form data" is selected. 

Alternative: tFileFetch
 

If tHTTPClient continues to fail, many users successfully use tFileFetch for multipart uploads:
 

  • Go to Advanced Settings.
  • Check the box Upload files.
  • Add your file in the table:
    • Name: The form field name (e.g., "file").
    • File: Full path to the PDF.
    • Content-Type: application/pdf. 

Troubleshooting Tips
 

  • Check the Schema: Ensure your tHTTPClient output schema includes status, headers, and body (type String) to correctly capture the server's response for debugging.
  • Manual Java Routine: If the built-in components fail due to complex API requirements, you can use a Java Routine to create a custom HttpURLConnection that manually builds the multipart boundary and streams the file

 

bonacq
Contributor
Contributor
Author

Hi,

Thanks for the quick reply.
I've done everything except this point.

  • Change the Type for this specific row to File (this is critical for the component to treat the value as a file stream rather than a text string).

bonacq_0-1776238412449.png

I can't find where to set "Files."


Thanks