getLocationNoteAttachment

POST public/getLocationNoteAttachment

Returns a note's attachment, with the file content base64-encoded.

Request syntax

curl https://apiv2.acumera.net/public/getLocationNoteAttachment \
  --cookie av_session.txt \
  --data-urlencode "location_note_id=<location_note_id>" \
  --data-urlencode "filename=<stored_filename>"

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_note_id Integer The ID of the note. Yes
filename String The attachment's stored filename, exactly as getLocationNote or getLocationNotes returns it, for example rack_1793398094.png. Yes

Response syntax

{
    "success": "string",
    "data": {
        "location_note_attachment": {
            "location_note_id": "string",
            "filename": "string",
            "file_description": "string",
            "file_created": "string",
            "file_created_by": "string",
            "content_length": "string",
            "content_type": "string",
            "file_content": "string",
            "location_id": "string"
        }
    }
}

Response parameters

If the call succeeds, success is "1" and the following data is returned. All values are strings.

Field Description
location_note_id The ID of the note.
filename The attachment's stored filename.
file_description The attachment's description.
file_created When the file was attached, as a Unix timestamp.
file_created_by The user ID of the person who attached it.
content_length The file size in bytes.
content_type The file's MIME type, for example image/png.
file_content The file, base64-encoded.
location_id The location the note belongs to. A company-level note has company_id instead.

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_NOTE_SELECTED No note was selected. location_note_id is missing or isn't a number.
NOTE_NOT_FOUND The note was not found. No note has that ID.
AUTH_FAILED_FUNC_NOT_ALLOWED Authorization failed because you are not permitted to access the requested function. The note is private, or your account doesn't have access to its location or company.
MISSING_FILENAME No filename supplied. filename is missing or empty.
FILE_NOT_FOUND The file was not found. The note has no attachment, or filename doesn't match its stored filename.
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: Download a note's attachment

curl https://apiv2.acumera.net/public/getLocationNoteAttachment \
  --cookie av_session.txt \
  --data-urlencode "location_note_id=123457" \
  --data-urlencode "filename=rack_1793398094.png"

Response (file_content shortened):

{
    "success": "1",
    "data": {
        "location_note_attachment": {
            "location_note_id": "123457",
            "filename": "rack_1793398094.png",
            "file_description": "Network rack",
            "file_created": "1793398094",
            "file_created_by": "1001",
            "content_length": "1827",
            "content_type": "image/png",
            "file_content": "iVBORw0KGgoAAAANSUhEUgAAAFUAAAA4CAYAAACMn7Te...",
            "location_id": "4510"
        }
    }
}

To save the file, decode file_content from base64. For example, with jq:

curl -s https://apiv2.acumera.net/public/getLocationNoteAttachment \
  --cookie av_session.txt \
  --data-urlencode "location_note_id=123457" \
  --data-urlencode "filename=rack_1793398094.png" \
  | jq -r '.data.location_note_attachment.file_content' | base64 --decode > rack.png

Example: Use the original filename instead of the stored filename

SC//AcuVigil adds a timestamp to an attachment's filename when it's stored. If you send the original name, the call fails:

{
    "success": "0",
    "returnCode": "FILE_NOT_FOUND",
    "returnMessage": "The file was not found."
}