One Star

How can I upload a file to REST API?

I am trying to invoke a REST API to load data to a third party provider. My payload should include the csv file itself and data mapping wrapping in a json message. The following CURL command works fine in uploading the file, but I can't seem to make this work in Talend:
curl -v -X POST -H "Content-Type: multipart/form-data" -H "loginName: thisismylogin@name" -H "appOrgId: thisismyorgID" -H "accessKey: thisismysecretaccesskey" --form "file=@" --form 'metadata={"collectionName":"data_load_a83082482aeb4fc58d75bc7f4ee1ade1","dataLoadOperation":"INSERT","mapping":,"sourceType":"FILE","headerRow":true,"fieldSeparator":",","escapeCharacter":"\\","quoteCharacter":"\"","dbNameUsed":true,"invokedFromGDM":false};type=application/json' -k
This curl command sends the file with a json message defining what the file looks like, and third party api loads the file. I couldn't figure out how I could configure this on Talend. Which component I should be using? (tRest?) And if it is tRest, what's HTTP body should look like? Any help is very much appreciated. 

Re: How can I upload a file to REST API?

Have you already checked component tRestClient to post a request with your json format?
Here is the component reference:TalendHelpCenter:tRESTClient
Best regards
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.