{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":484,"path":"api-reference/rest-apis/cccif-api.md","title":"CCCIF Media Resource API","bundle":null,"doc_type":null,"release":"australia","body":"\n# CCCIF Media Resource API\n\nThe Custom Chat Chatbot Interoperability Framework \\(CCCIF\\) Media Resource API provides endpoints that enable a primary bot to upload attachments to the associated ServiceNow instance.\n\nCall this API in your primary bot to upload private attachments from a user that is having a conversation through Virtual Agent \\(VA\\). You must then send the mediaUrl parameter that is returned by this API to the VA API.\n\nIf the attachment is public, you can just send the attachment URL in the request body of your [Virtual Agent Bot Integration](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/bot-api.md) call.\n\nTo access this API, the Conversational Custom Chat Integration \\(com.glide.cs.custom.adapter\\) plugin must be activated. In addition, the attachment system properties must be configured.\n\nFor additional information on the capabilities of the Virtual Agent API, see [Virtual Agent API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/conversational-interfaces/virtual-agent-api-landing-page.md).\n\n**Parent Topic:**[REST API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/api-rest.md)\n\n## CCCIF - POST /cccif/media/upload\n\nUploads a private attachment to the called ServiceNow instance which stores the attachment in the Attachments \\[sys\\_attachment\\] table.\n\nCall this method in your primary bot to upload private attachments from a user that is having a conversation through Virtual Agent \\(VA\\). You must then send the mediaUrl parameter that is returned by this method to the VA API using the [Virtual Agent Bot Integration API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/bot-api.md).\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/cccif/media/upload`\n\nDefault URL: `/api/now/cccif/media/upload`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfile\n\n</td><td>\n\nRequired. Path of the file to upload.Data type: String, such as @File path &lt;file\\_path&gt;\n\n</td></tr><tr><td>\n\nprovider\\_application\\_id\n\n</td><td>\n\nSys\\_id of the sys\\_cs\\_provider\\_application interacting with the VA bot.Default: Sys\\_id of the VA Bot to Bot Provider Application\n\n</td></tr><tr><td>\n\nuser\\_id\n\n</td><td>\n\nRequired. Unique user identifier of the user interacting with the VA bot. This can be any string that is unique for each user.Data type: String\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Header|Description|\n|------|-----------|\n|Accept|Data format of the response body. Supported types: **multipart/form-data**.|\n\n|Header|Description|\n|------|-----------|\n|Content-Type|Data format of the response body. Only supports **application/json**.|\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|201|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|404|Not found. The requested item wasn't found.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON\\)\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nattachmentId\n\n</td><td>\n\nSys\\_id of the attachment that was stored.Data type: String\n\n</td></tr><tr><td>\n\nerror\n\n</td><td>\n\nDescription of any error detected while processing the request.Data type: Object\n\n```\n\"error\": {\n  \"detail\": \"String\",\n  \"message\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nerror.detail\n\n</td><td>\n\nDetails about the error that was encountered.Data type: String\n\n</td></tr><tr><td>\n\nerror.message\n\n</td><td>\n\nMessage describing the error that was thrown.Data type: String\n\n</td></tr><tr><td>\n\nmediaUrl\n\n</td><td>\n\nAttachment URL to send to the primary bot to access the attachment. The primary bot must send this URL in the **message.attachment.url** parameter of the request body of the POST /sn\\_va\\_as\\_service/bot/integration endpoint.Data type: String\n\n</td></tr><tr><td>\n\nname\n\n</td><td>\n\nFile name of the attachment.Data type: String\n\n</td></tr><tr><td>\n\nstate\n\n</td><td>\n\nState of the attachment in the Attachment table.Possible values:\n\n-   available\n-   conditionally available\n-   not available\n-   pending\n\nData type: String\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example shows how to upload a .png file attachment.\n\n```\ncurl --location --request POST 'https://instance.servicenow.com/api/now/v1/cccif/media/upload' \\\n--header 'Authorization: Basic xxxxxxxxxxxxx' \\\n--header 'Content-Type:multipart/form-data' \\\n--form 'user_id=\"lincoln\"' \\\n--form 'file=@\"/Users/Desktop/Screenshot 2021-10-25 at 5.08.14 PM.png\"'\n\n```\n\nResponse:\n\n```\nResponse :{\n  \"result\": {\n    \"mediaUrl\": \"https://instance.servicenow.com/api/now/v1/cs/media/vGfewkfAv0VBo2RxmlTM448L789Pp6rqLFLUNYQxZsUUFrsgMA8aW9W0zWx1a5fG\",\n    \"name\": \"Screenshot 2021-10-25 at 5.08.14 PM.png\",\n    \"state\": \"pending\",\n    \"attachmentId\": \"299c648887b73c1022b6a6cd0ebb3534\"\n  }\n```\n\n"}}