How would I go about translating the following curl command to a Jitterbit operation?
curl -i -u username:password -X POST -F file=@/path/to/file.csv
https://website.com/api/filepost
Currently I have my Operation structured as follows:
Script:
$jitterbit.target.http.form_data = true; $jitterbit.target.http.form_data.filename = "file.csv"; $jitterbit.target.http.form_data.name = "file";
Source A CSV file without headers, which matches the API's specifications (sent the same file successfully via curl)
Transformation: Text to Text - both source and target use the same file format as the Source file
Currently I authenticate successfully, but I get a 400/Bad Request error message saying "No file attached".
Full error message:
The operation "2. POST Preapplicants - CSV to API" failed.
Fatal Error
Failed to post to the url 'https://website.com/api/filepost’.
The last (and probably most relevant) error was: The server
returned HTTP Status Code : 400 Bad Request Error is: The
request could not be processed by the server due to invalid
syntax. Headers sent by the server: HTTP/1.1 400 Bad Request
Server: nginx/1.10.3 (Ubuntu) Content-Type: application/json
Transfer-Encoding: chunked Connection: keep-alive Cache-Control:
no-cache Date: Tue, 12 Sep 2017 18:55:38 GMT The response was:
{"message":"No file attached."}
I solved this problem by doing the following: 1. Changing from a transformation operation to an archive operation (using the same source, target, and script) 2. Changing the content-type of my HTTP connection to multipart/form-data (the default content-type passed by curl)