Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

Available from CRM.COM R11.0.0

Table of Contents
maxLevel2

GET attachments/list

This method returns the attachments related with a specific entity. Multiple attachments are returned by each call.

Resource URL

Parameters

Name

Type

Description

token

String

The token retrieved from the login method

entity

(mandatory)

String

The name of the entity related with the attachment. The supported entities are the following:

  • ACCOUNTSRECEIVABLE
  • ACTIVITIES
  • COMMUNICATIONS
  • CONTACTINFORMATION
  • INSTALLEDITEMS
  • JOBS
  • LEADS
  • PRODUCTS
  • SERVICEREQUESTS
  • ATTACHMENTSLIBRARY
Tip

ATTACHMENTSLIBRARY is Available from CRM.COM R12.2.0

entity_id

(mandatory on conditions)

String

The ID of the entity related with the attachment, which is mandatory only if the entity is not set to ATTACHMENTSLIBRARY

Tip

The entity ID is mandatory up to CRM.COM R12.1.0

From CRM.COM R12.2.0 the entity ID is mandatory on conditions

classification

(mandatory on conditions)

String

The classification of the attachment, which is mandatory only if the entity is set to ATTACHMENTSLIBRARY

Tip

Available from CRM.COM R12.2.0

fields_set
(optional)

List of Strings, comma separated 

A list of fields that should be included in the results. If not specified then all the available fields will be returned

Restrictions

  • It is mandatory to specify at least one of the semi-optional parameters. Only one of those parameters is allowed to be specified.

Response Data

...

Examples

Expand
titleExample 1

HTTP Method: GET

 

Request:

Response:

Code Block
themeConfluence
languagejs
linenumberstrue
 {
  "data": [
    {
      "comments": "polina",
      "file": {
        "file_name": "bill subscriber error.txt",
        "file_content_url": "/crm/FileDownloadServlet?id=01239852D674447D88374321FD922E7A",
        "file_mime_type": "text/plain"
      },
      "log_information": {
        "created_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "updated_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "created_date": "2016-11-03T13:42:06",
        "updated_date": "2016-11-03T13:42:06",
        "updated_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        },
        "created_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        }
      },
      "id": "01239852D674447D88374321FD922E7A",
      "entity_id": "10A149D60365488AB53DCB889CFD98F8",
      "entity": "ACCOUNTSRECEIVABLE",
      "url": null
    },
    {
      "notes": "polina",
      "file": {
        "file_name": "bill subscriber error.txt",
        "file_content_url": "/crm/FileDownloadServlet?id=479FAB4E732B44EAA66B41522A5AE126",
        "file_mime_type": "text/plain"
      },
      "log_information": {
        "created_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "updated_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "created_date": "2016-11-03T13:34:29",
        "updated_date": "2016-11-03T13:34:32",
        "updated_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        },
        "created_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        }
      },
      "id": "479FAB4E732B44EAA66B41522A5AE126",
      "entity_id": "10A149D60365488AB53DCB889CFD98F8",
      "entity": "ACCOUNTSRECEIVABLE",
      "url": null
    },
    {
      "notes": "test",
      "file": {
        "file_name": "bill subscriber error.txt",
        "file_content_url": "/crm/FileDownloadServlet?id=0B8B13EFADF34D9899F633639F6D460E",
        "file_mime_type": "text/plain"
      },
      "log_information": {
        "created_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "updated_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "created_date": "2016-11-03T13:26:08",
        "updated_date": "2016-11-03T13:28:06",
        "updated_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        },
        "created_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        }
      },
      "id": "0B8B13EFADF34D9899F633639F6D460E",
      "entity_id": "10A149D60365488AB53DCB889CFD98F8",
      "entity": "ACCOUNTSRECEIVABLE",
      "url": null
    },
    {
      "notes": null,
      "file": {
        "file_name": "bill subscriber error.txt",
        "file_content_url": "/crm/FileDownloadServlet?id=927EEC9B3C16495B9A76B0D4219687C2",
        "file_mime_type": "text/plain"
      },
      "log_information": {
        "created_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "updated_by_unit": {
          "alternative_code": "adminunit",
          "name": "Admin Unit",
          "description": "admin unit",
          "id": "1"
        },
        "created_date": "2016-11-02T13:21:04",
        "updated_date": "2016-11-02T13:21:06",
        "updated_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        },
        "created_by_user": {
          "person_name": "MPAdministrator",
          "id": "1",
          "username": "MPAdministrator"
        }
      },
      "id": "927EEC9B3C16495B9A76B0D4219687C2",
      "entity_id": "10A149D60365488AB53DCB889CFD98F8",
      "entity": "ACCOUNTSRECEIVABLE",
      "url": null
    }
  ],
  "status": {
    "code": "OK",
    "description": "",
    "message": ""
  }
}

Note:

To retrieve or display the actual image you need to construct the following URL

Code Block
languagexml
{{server}}{{file_content_url}}&token={{token}}  

for example

Code Block
languagexml
https://r11qa.crm.com/crm/FileDownloadServlet?id=927EEC9B3C16495B9A76B0D4219687C2&token=B18ECEE5918442A0A29B7C1B2D0A4260

POST attachments/add

This method is used to add attachments on an existing entity.  This Web API method requires a multipart/form-data post, as defined in RFC 1867. There are many libraries available that can be used in order to submit multipart/form-data posts (for example MultipartEntity in Java). A single attachment can be added through each call

Resource URL

Parameters

Name

Type

Description

token

String

The token retrieved from the login method

entity

(mandatory)

String

The name of the entity related with the attachments that should be returned as a result. The supported entities are the following:

  • ACCOUNTSRECEIVABLE
  • ACTIVITIES
  • COMMUNICATIONS
  • CONTACTINFORMATION
  • INSTALLEDITEMS
  • JOBS
  • LEADS
  • PRODUCTS
  • SERVICEREQUESTS
  • ATTACHMENTSLIBRARY
Tip

ATTACHMENTSLIBRARY is Available from CRM.COM R12.2.0

entity_id

(mandatory on conditions)

String

The ID of the entity related with the attachments that should be returned as a result, and is mandatory only if the entity is not set to ATTACHMENTSLIBRARY

Tip

The entity ID is mandatory up to CRM.COM R12.1.0

From CRM.COM R12.2.0 the entity ID is mandatory on conditions

file

(semi-optional)

FileThe file that should be added as an attachment

url

(semi-optional)

StringThe URL that should be added as an attachment

classification

(mandatory on conditions)

String

The classification of the attachment, and is mandatory only if the entity is set to ATTACHMENTSLIBRARY

Tip

Available from CRM.COM R12.2.0

notes

(optional)

StringThe notes related with the attachment

fields_set
(optional)

List of Strings, comma separated 

A list of fields that should be included in the results. If not specified then all the available fields will be returned

Restrictions

  • It is mandatory to specify one of the semi-optional parameters. Only one of those parameters is allowed to be specified.

Response Data

...

Examples

Expand
titleExample 1

cURL Example:

Code Block
languagetext
linenumberstrue
 curl --request POST \
  --url {{server}}/crmapi/rest/v2/attachments/add \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form entity=CONTACTINFORMATION \
  --form 'token={{token}}' \
  --form entity_id=18686813304341ECAFC8175A85594C9B \
  --form 'notes=My Web API notes' \
  --form url=www.crm.com \
  --form 'file=@[object Object]'

 

PHP Example:

Code Block
languagephp
linenumberstrue
 <?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{server}}/crmapi/rest/v2/attachments/list?token={{token}}&entity=CONTACTINFORMATION&entity_id=18686813304341ECAFC8175A85594C9B",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

POST attachments/delete

This method is used to delete attachments.  A single attachment can be deleted through this method

Resource URL

Parameters

Name

Type

Description

token

String

The token retrieved from the login method

id

(mandatory)

String

The id of the attachment that should be deleted

 

Response Data

Not applicable

Examples

HTTP Method: POST

 

Request:

Body:

Expand
titleExample 1
Code Block
themeConfluence
languagejs
linenumberstrue
 {
"token":"{{token}}",
"id":"F7FF2E30AAD94720B844B1035B195955"
} 

 

Response:

Not applicable Panel
nameblue

Child pages (Children Display)
alltrue
excerpttrue