Some API resources may have relationships with files. Examples may be:
- a user picture ;
- a work-contract attachment ;
- etc…
Upload a file
First upload a file through the file-upload API endpoint.
POST /lucca-files/api/uploads HTTP/1.1
Host: example.ilucca.net
Authorization: lucca application={API_KEY}
Accept: application/json
Content-Type: multipart/form-data; boundary=---abc
-----abc
Content-Disposition: form-data; name=""; filename="test.pdf"
-----abc--
Make sure to keep the id given in the response, you’ll need it later.
Set the file id as a reference on the object
You then need to set the uploaded file id on the corresponding resource.
PUT /api/v3/users/416 HTTP/1.1
Host: example.ilucca.net
Authorization: lucca application={API_KEY}
Accept: application/json
Content-Type: application/json
{
"picture": {
"id": "618d5bac-2f38-4d5b-8ba3-981733dffeff"
}
}