Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
DVi7
Contributor

How to extract fields from multipart/form-data on a Talend job

Hi to all! I want to build a webservice in Talend able to receive json and file at the same time. I am using the following call in python:

   import requests

   url="http://localhost:8088/trial"

   data = {

     'var1' : 'this',

     'var2' : 'that'

   }

   headers = {'Content-Type': 'application/json'}

   files = {'document': open('C:/Users/User/Desktop/Data/Talend/Mail/sample.pdf', 'rb')}

   r = requests.post(url, files=files, data=data, headers=headers)

   print(r.status_code)

Below a screenshot of the job in Talend:

0695b00000DuTi6AAF.png

The Issue is that inside my Talend job i am unable to retrieve the values from 'var1' and 'var2' because they arrive as multipart/form-data. How can I fetch them in my tJavaRow_1? Any suggestion about that?

Thank you in advance!

Labels (2)
2 Replies
gjeremy1617088143

HI could you send us the component view of the tRestRequest? You can choose Produces JSON in the parameters of the tRestRequest and after use a tExtractJSONFields to fetch the JSON.

Send me love and Kudos

DVi7
Contributor
Author

Hi gjeremy ! Thank you for answering my question. Here's a pic of the tRestRequest as you asked .

0695b00000Duy21AAB.png 

I've already tried the solution that you suggest but it didn't work in my case. On this purpose I want to show you how the data arrives in the first tLogRow_1.

 

0695b00000Duy26AAB.pngp.s the payload in tRestRequest has byte[] as datatype.