$ curl -v -u user:pass -H 'Accept: application/json' -H 'Content-Type: application/json' \
-d '{}' https://appname.remotex.net/api/files/
< HTTP/2 201
< content-type: application/json
< content-length: 421
< location: https://appname.remotex.net/api/files/19102101595
< etag: "1"
< apistatusmessage: Created
{"Id":"19102101595","CRMSystemId":"","Title":"","Description":"","FileName":"",
"ContentType":"","Length":0,"Content":{"Title":"","Href":"files/19102101595/"},
"Created":"2019-10-21T16:11:03.8153302Z","Updated":"2019-10-21T16:11:03.8153302Z",
"CreatedBy":{"Href":"users/user","Title":"User"},"UpdatedBy":{"Href":"users/user","Title":"User"},
"Href":"files/19102101595","Revision":1,"ContentHash":""}
$ curl -v -u user:pass -T ./cat1.jpg -X PUT https://appname.remotex.net/api/files/19102101595/cat1.jpg
< HTTP/2 204
< apistatusmessage: No Content
The following command batch will attach the uploaded file to the case at /api/cases/191003-3897
.
The command batch response succeeds when HasErrors = false
. The resources changed by the command are
listed in the AffectedItems
array of each command result.
$ curl -v -u user:pass -H 'Accept: application/json' -H 'Content-Type: application/json' \
-d '{"Commands":[{
"Name":"AddAttachmentToCase",
"Target":"cases/191003-3897",
"Parameters":[{"Name":"File","Values":["files/19102101595"]}]
}]}' https://appname.remotex.net/api/commands/
< HTTP/2 OK
< content-type: application/json
< content-length: 415
< apistatusmessage: OK
{
"Href":"commands/",
"HasErrors":false,
"Received":"2019-10-21T16:07:53.0885076Z",
"Commands":[
{
"HasErrors":false,
"AffectedItems":[{"Href":"files/19102101595","Revision":"5"},{"Href":"cases/191003-3897","Revision":"4"}],
"Command":{"Name":"AddAttachmentToCase","Target":"cases/191003-3897","Parameters":[{"Name":"File","Values":["files/19102101595"],"Value":"files/19102101595"}]},
"Code":"Success"
}
],
"ErrorMessages":""
}
Note: Skipping step 2 would attach an empty file to the case and could break other integrations expecting all attached files to have filename and content.