API – Add a File

action – addfile

Files of almost any sort can be stored against a record. The API call to add a file requires that the file be presented as a base64-encoded data URI e.g. ‘data://;base64,[encoded data]’ where [encoded data] is a base64-encode of the binary contents of the file. This syntax is chosen as it allows for any binary file content to be uploaded to PYXI using a standard JSON API call, rather than introducing a more complex mechanism to reliably receive binary data.

The resulting file will be created in the ‘root’ file directory of the record specified, or alternatively in a sub-folder of the root if ‘folder’ is specified as an alpha-numeric folder name. Please note that multi-level nested sub-folders are not supported by this call.

The record id of the file is returned in recordid.

Sample Request

{ "account": *** your account id ***, "apikey": "*** your api key ***", "action": "addfile", "recordurl": "person/12345", "filename": "myfile.jpg", "folder": "MyFolder", "content": "data://;base64,……" }

Sample Response

{ "success": true, "recordid": 8765432 }