addLocationPhoto

POST public/addLocationPhoto

Adds a photo to a location. SC//AcuVigil also creates a thumbnail.

Request syntax

curl https://apiv2.acumera.net/public/addLocationPhoto \
  --cookie av_session.txt \
  --data-urlencode "location_id=<location_id>" \
  --data-urlencode "filename=<filename>" \
  --data-urlencode "content_type=<mime_type>" \
  --data-urlencode "content_length=<size_in_bytes>" \
  --data-urlencode "image_content=<base64_image_content>" \
  [--data-urlencode "description=<description>"]

Optional parameters are shown in brackets. The username, password, and tfa_token parameters are also accepted, and are required only if the client hasn't already signed in with login. See Getting started with the SC//AcuVigil API.

Request parameters

The request accepts the following parameters in a form-encoded body.

Parameter Type Description Required Default value
location_id Integer The ID of the location. Yes
filename String The photo's filename, for example rack.png. Yes
content_type String The image's MIME type, for example image/png. Yes
content_length Integer The image's size in bytes. It must be a number; SC//AcuVigil records the image's actual size. Yes
image_content String The image, base64-encoded. Yes
description String A description of the photo. Letters, numbers, spaces, and # & ' + , - . / _ only. No The filename without its extension

Response syntax

{
    "success": "string",
    "returnCode": "string",
    "returnMessage": "string"
}

Response parameters

Field Description
success "1" if the photo was added.
returnCode FILE_UPLOADED when the photo was added.
returnMessage A description of the result.

The response doesn't include the new photo's ID. The photo is stored with a timestamp added to its filename, for example rack.png becomes rack_1793398093.png. To get the ID and stored filename, call getLocationPhotos.

Errors

If the call fails, success is "0", and returnCode and returnMessage describe the problem. The HTTP status is still 200.

Return code Message Cause
NO_LOCATION_SELECTED No location was selected or the location does not exist. location_id is missing or isn't a number.
LOCATION_NOT_FOUND The location was not found. No location has that ID.
AUTH_FAILED_FUNC_NOT_ALLOWED Authorization failed because you are not permitted to access the requested function. Your account doesn't have access to the location.
MISSING_FILENAME No filename supplied. filename is missing or empty.
MISSING_CONTENT_TYPE The Content-Type value was not supplied. content_type is missing or empty.
MISSING_CONTENT_LENGTH The Content-Length value was not supplied. content_length is missing or isn't a number.
MISSING_IMAGE_CONTENT The image content was not supplied. image_content is missing or empty.
INVALID_DESCRIPTION Description contains invalid characters. description contains a character that isn't allowed.
INVALID_LOGIN We were unable to log you in. Make sure you entered the correct username, password and 2FA code. You haven't signed in, your session has ended, or the credentials sent with the call are wrong.

Examples

Example: Upload a photo from a file

This example uploads rack.png. The shell base64-encodes the file and measures its size.

curl https://apiv2.acumera.net/public/addLocationPhoto \
  --cookie av_session.txt \
  --data-urlencode "location_id=4510" \
  --data-urlencode "filename=rack.png" \
  --data-urlencode "content_type=image/png" \
  --data-urlencode "content_length=$(wc -c < rack.png | tr -d ' ')" \
  --data-urlencode "image_content=$(base64 < rack.png | tr -d '\n')" \
  --data-urlencode "description=Network rack"

Response:

{
    "success": "1",
    "returnCode": "FILE_UPLOADED",
    "returnMessage": "The file was uploaded successfully."
}

Example: Leave out the image content

{
    "success": "0",
    "returnCode": "MISSING_IMAGE_CONTENT",
    "returnMessage": "The image content was not supplied."
}