Send a job uploading a file
In order to create a simple conversion of a file located on your computer or server you will need to:
- Send a job without any input files
- The response should contain the keys id and server
{ "id": "abcdd66e-bfb6-4ef3-b443-787131bb84b3", ... ... "server": "https://wwwXX.api2convert.com/v2/dl/webX" ... ... }
- Retrieve the
server
andid
keys from the response - Concatenate the
server
value with/upload-file/
and theid
value
The resulting string should look like this:
https://wwwXX.api2convert.com/v2/dl/webX/upload-file/abcdd66e-bfb6-4ef3-b443-787131bb84b3
This is just an example. Make sure to use the values you get in the response of the create job call.
POST /v2/jobs HTTP/1.1
Host: api.api2convert.com
x-oc-api-key: <your API key here>
Content-Type: application/json
Cache-Control: no-cache
{
"conversion": [{
"category": "image",
"target": "png"
}]
}
curl -X POST \
https://api.api2convert.com/v2/jobs \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'x-oc-api-key: <your API key here>' \
-d '{
"conversion": [{
"category": "image",
"target": "png"
}]
}'
After generating the URL you will have to do a
POST
request to it.
The field file
is where you put the contents of the file you
want to send.
The optional field decrypt_password
is where you put the
password to open a password protected file.
Once the file is uploaded, the job will continue its lifecycle, start processing the conversion and eventually finish.
Please note that, even if not mandatory, it's highly recommended to set a unique random string for each file that you upload. This can prevent conversion problems in some corner cases. You don't need to send a full UUID, a short random string should be enough.
POST /v2/dl/web2/upload-file/39ef70ea-efc8-42a2-84dc-2090e1055077 HTTP/1.1
Host: www13.api2convert.com
x-oc-api-key: <your API key goes here>
x-oc-upload-uuid: <your random string or a full UUID>
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="decrypt_password"
this_is_a_password
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="myfile.png"
Content-Type: image/png
... contents of the file go here ...
------WebKitFormBoundary7MA4YWxkTrZu0gW--
curl -X POST \
https://www13.api2convert.com/v2/dl/web2/upload-file/39ef70ea-efc8-42a2-84dc-2090e1055077 \
-H 'cache-control: no-cache' \
-H 'x-oc-api-key: <your API key here>' \
-H 'x-oc-upload-uuid: <your random string or a full UUID>' \
-F file=@/path/to/image.png
-F decrypt_password=this_is_a_password