Views:

This article is for an API Partner wanting to upload a file attachment to an attachment question.  

Contents

Summary

Gives the API Partner the ability to add an attachment to an attachment question within the Discloser’s questionnaire-response.

Pre-requisites: Valid subscription key, organization UUID and question ID for the relevant attachment question in the respective Disclosure API environment. 

Note - Question Type: Files can only be attached to questions with the “ATTACHMENT” type. Once attachments have been added, the file metadata is returned via the GET /response endpoint.

Note - Delete File: Attachment files can only be removed from the front-end of the response system in the current build.  

POST Request

Details on how to complete the POST request to add a file attachment to an attachment question.
 

Note - Restrictions: File type and size restrictions apply to the POST request as in the CDP Response Portal:

  • Supported file types: PDF, DOCX, DOC, XLSX, XLS, CSV, PPTX, PPTXS

  • File size: 50Mb

URLs

Sandbox: https://api.pre.cdpgreenstar.net/asp/response/response/file

Production: https://api.cdp.net/response/response/file

Headers/Variables

subscription-key (header):  For authorized user, the subscription key.

organization-id (header):  A valid partner organization ID is required.

Body

questionId: Question ID of a file attachment question.

file: Valid file attachment (see above).
 
rowId: Row id if the attachment question is within a matrix question (currently all are within a matrix question).

Response

Field table
 

Field

Description

Data Type

id

The ID of the generated file within the response.

integer

fileName

The name of the file which was uploaded.

string

fileSize

Size of the file attached.

integer

fileType

The type of file which was uploaded.

string

fileStatus

The status of the upload request.

string

Schema
 
{
"id": integer,
"fileName": "string",
"fileSize": integer,
"fileType": "string",
"fileStatus": "string",
}
 

Error Handling

1. Invalid Subscription Key

When an incorrect or invalid subscription key is entered, the following error is displayed:
 

{
"message": "Invalid subscription key",
"error": "Unauthorized",
"statusCode": 401
}

2. Invalid Organization ID

When an invalid organization key is entered, the following error is displayed:
 

{
"message": "Invalid organization id",
"error": "Unauthorized",
"statusCode": 401
}

3. Invalid questionId

When an invalid questionId is entered, the following error is displayed:
 

{
"statusCode": 500,
"error": “Internal server error”
}


Note: This is not the only reason this error might be returned. We have an item on our backlog to improve the error messaging in this case.

4. Invalid rowId

When an invalid rowId is entered, the following error is displayed:
 

{
"statusCode": 500,
"error": "Error updating response"
}

5. Invalid file type

When an invalid file type is entered, the following error is displayed:
 

{
"message": "The file is not supported"
"fileFormat": "application/json"
"supportedFileFormat": [

                    "PDF",

                    "CSV",

                    "DOCX",

                    "DOC",

                    "XLSX",

                    "XLS",

                    "PPTX",

                    "PPT",
             ],

"statusCode": 400,
 "error": “Bad Request”
}

6. File is too big

When a file that is too big is entered, the following error is displayed:
 

{
"message": "The file is too big"
"fileSize": 84696258,
"maxFileSize": 52428800,
"statusCode": 400,
"error": "Bad Request"
}

GET/PUT/DELETE Requests

GET requests are not implemented for this endpoint, preventing the retrieval of files attached to a response. File metadata is returned via the /response/response endpoint.

PUT requests are not implemented for this endpoint, as once a file is attached to a response it cannot be updated or overwritten. 

DELETE requests are not implemented for this endpoint, preventing deletion of files and file metadata. 



If you have not found the answer you were looking for, please contact your Account Manager who will be able to assist you further.

Comments (0)
Add a comment