1. Home
  2. /
  3. Developer Guide
  4. /
  5. Rest API
  6. /
  7. 6. Upload File

6. Upload File

  • URL:
« /RestApi/UploadFile»
  • Method: POST
  • Authentication: Include an OAuth 2.0 access token in the Authorization: Bearer <access_token> header of every call. See 1. AuthToken — OAuth 2.0 Authentication for how to obtain one.
  • URL Params:
    • fileName [string] [Required]=the name of the file that the user wants to upload
    • objectName [string] [Required]=the name of the record’s object that the user wants to upload the file to
    • fieldName [string] [Required]=the API name of the field that the file will be uploaded to
    • RecGUID [long] [Required]=the record Id in CirrusShield that the file will be uploaded to
  • Data Params:
    • dataStream =the data of the uploaded file

Example:

// Get file name

$fileName = $_FILES['file_upl']['name'];
// Get file content

$data = file_get_contents($_FILES['file_upl']['tmp_name']);
// Transform file content to json array

$array = array();

foreach(str_split($data) as $char){
array_push($array, ord($char));
}
// Send the Data Params

curl_setopt($client, CURLOPT_POSTFIELDS, "=".json_encode($array));
<form name="file_up" action="UploadFile.php" method="POST" enctype="multipart/form-data">
Upload your file here

<input type="file" name="file_upl" id="file_upl"/>

<input type="submit" name="action" value="submit"/>
</form>
  • Success Response :
    • Status Code=200 (OK)
  • Error Response:
    • Status Code=400 (BadRequest) (in case there is an error in the json data sent in the HTTP Post Request body or if the object name, API field name in the object or record id are wrong)
Was this article helpful to you? No Yes

How can we help?