Views:

This article is for an API Partner wanting to make edits to a discloser’s response in the questionnaire-response Portal

Contents

Summary

This article covers the PUT request, used to update a Discloser’s questionnaire-response.

Pre-requisites: Valid subscription key and organization UUID for the respective Disclosure API environment.

Guidelines

  1. All questions that are part of the Discloser’s response can be retrieved and updated.

  2. It will only be possible to PUT when the response workflow status is set to IN PROGRESS or AMENDMENTS (i.e., it is not possible to send a PUT request once a response is To check the status of a questionnaire call GET - Questionnaire metadata submitted).

  3. When a value is updated into a question which has been hidden by show/hide conditional logic, the value is stored until the response is submitted. Should the question become visible again (if the answer to a lead question changes), the previously hidden value would be included in the submission. Response data includes a isHidden status flag indicating whether the question is visible to the user in the portal. To check the isHidden property, call the GET - Retrieve a Discloser's Response endpoint).

  4. To answer an expression (auto-calculation) question, an update must be sent based on the formulas provided by the GET - Expressions endpoint. The fields do not auto-calculate when the dependent questions are updated.

  5. Answers sent to an expression (auto-calculation) question will not be validated by the CDP Portal. You must ensure the calculation is performed correctly before sending the value.

  6. A GET request can be sent after a PUT request to verify the update to the data.

  7. When updating a matrix question a rowId must be provided or the update cannot be stored against the question.

  8. Send a null value to reset:

    • A numeric or rich text question.

    • A date.

    • Single/multi select and/or grouped options questions.

PUT Request

The information provided below shows how to structure a request to update a Discloser’s questionnaire-response, for each question type. This shows each question type in isolation, however, it is expected that multiple question updates are sent together.

Note: All fieldnames throughout the API are formatted using camel casing.

Known limitation: Large batch updates

Requests that update a very large number of matrix cells in a single call (roughly 2,000 or more) currently fail with an error rather than being processed. This affects responses to matrix questions with many added rows.

Workaround: Split large updates into smaller batches, around 1,000 cells per request is a safe upper limit and submit them sequentially. Each batch is processed independently, so a failure in one batch does not roll back previously submitted batches.

URLs

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

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

Headers/Variables

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

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

Body

Field table
 

Field

Description

Data Type

id

The ID of the row to be updated.

Note: A rowID must be provided when updating a matrix question or the data is lost. For a Matrix question, enter the corresponding rowID for the question only.

string

updateResponseInput

Additional info regarding the content and status update to be made:

  • content:

    • The ID AND name for an option

    • OR/span>

    • The answer-value to be updated

  • status: the answer status for the question to change to (see below).

array


Note: The status field is the current state of the question in the Portal. These are for display purposes only; the Discloser should ensure their response is filled out correctly prior to final submission. The isHidden property is used to determine if a value is currently relevant to a Discloser’s response. To check the isHidden property, call the GET - Retrieve a Discloser's Response endpoint.

  1. "UNANSWERED"– The question has not yet been answered.

  2. "ANSWERED"– The question is answered or has been marked by the user as answered.

  3. "SKIPPED"– The question is marked as skipped by the user. No content has been filled.

  4. "REVIEWED"– The question is marked as reviewed.

  5. "PROGRESS" – The question is currently in the process of being answered (matrix questions only).

Note: All the statuses aside from ANSWERED and UNANSWERED only apply to top -level questions/do not apply to cells in matrix questions.

JSON Body (Generic Schema)

The example below shows a typical successful update. In practice, bulk updates should be sent to multiple questions simultaneously.
 

[{
"id": "string",
"rowId: "string",
"updateResponseInput": {
     "content": {}
     "status": "string",
            } 
}]

JSON Body (SINGLE_SELECT: Working example)

  1. Validation on single select is based on "id" and not "name". However, the name must be present and not null.


Standard option:
 

[{
"id": "17e2ad15-0270-449f-bb6e-c536f310d338",
"updateResponseInput": {
     "content": {
         "id": "1289be31-2d95-4a3d-aa66-a690dd63650e",
         "name": "Latin American Spanish",
         "isOther": false
            } ,
                "status": “ANSWERED”,
          }
}]

 

  1. The following shows how to configure the isOther value through the API. When done via the CDP portal, users must select the option “Other, please specify” and a description field is subsequently revealed to enable a custom text value to be added to the response.


Note: If the question is part of a matrix question, then the rowId needs to be included in the request.

“isOther” option (within a matrix question):
 

[{
"id": "17e2ad15-0270-449f-bb6e-c536f310d338",
"rowId": "ba00926f-b1bf-47be-abee-3682304590f2",
"updateResponseInput": {
     "content": {
         "id": "1289be31-2d95-4a3d-aa66-a690dd63650e",
         "name": "Other, please specify",
        "description": "CDP Test Other",
         "isOther": true
            } ,
                "status": “ANSWERED”,
          }
}]

JSON Body (MULTI_SELECT: Working example)

Validation on multi select is based on "id" and not "name". However, the name field must be present and not null.
 

[{
"id": "114d0b15-30b0-4715-90ed-7dd98d69df56",
"updateResponseInput": {
     "content": [{
         "id": "5f6d9d1e-8684-4b75-a6ac-9b738af73ef2",
         "name": "Afghanistan",
         "isOther": false
            }, {
         "id": "3802bb82-1161-4bd1-9f61-27aeec37c065",
         "name": "Åland Islands",
         "isOther": false
             }
          ], 
           "status": “ANSWERED”,
      }
}]

New for 2026: Ability to unselect Options

To unselect/clear all options for a select based question, a null content response can be sent.

[{
"id": "17e2ad15-0270-449f-bb6e-c536f310d338",
"updateResponseInput": {
     "content": null,
     "status": "UNANSWERED",
}]

 

JSON Body (NUMERIC: Working example)


[{
"id": "9f90f9e9-4f0d-4eae-a5f9-68289a5642ef",
"updateResponseInput": {
     "content": “100.12”,
     "status": "ANSWERED",
           } 
      }
]

Note: The numeric value entered should not contain commas. And should match any criteria set out in the validationRules.

JSON Body (DATE: Working example)

Note: The Date Format must be in ISO-8601 format.
 

[{
"id": "1271a1fd-b371-4a57-abea-91a8eb366a32",
"updateResponseInput": {
     "content": "2023-03-20T23:00:00.000Z",
     "status": "ANSWERED",
            } 
       }
]

JSON Body (RICH_TEXT: Working example)

Note: Rich text formatting cannot be inserted into rich text questions at column level in the current build. Any formatting entered will be taken as a literal string value.


[{
"id": "e04a5941-7ba1-4818-8260-abb7de7b3ec1",
"updateResponseInput": {
     "content": "Hello, world!",
     "status": "ANSWERED"
            } 
       }
]

JSON Body (MATRIX: Working example)

Updates to matrix questions can be made to both the parent and the child/column question(s) at the same time as shown. You cannot add content to the parent question as this does not hold any answer-value data.


[{
"id": "e0830fe7-1ff2-442b-8e59-d5eaff0bb6f2",
"updateResponseInput": {
     "content": null,
     "status": "PROGRESS",
            },{
 "rowId": "22dada94-a756-4f0b-9cc5-8062fb74c784",
 "id": "e04a5941=7ba1-4818-8260-abb7de7b3ec1",
 "updateResponseInput": {
                  "content": "2023-03-20T23:00:00.000Z",
                    "status": "ANSWERED"
           }
      } 
]


Note: If you update a matrix question value without adding a rowId then the update is lost, and no error is returned to flag this.

JSON Body (GROUPED_OPTIONS: Working example)

Known issue: As noted in the GET /questions endpoint some of the option names may contain whitespace that needs to be included for the update to be accepted.

[{
"id": "fd6bb39C-e4af-44d2-ae68-43e1f83d1bfc",
"updateResponseInput": {
     "content": [{
         "group": "2d64aaa0-7869-4a76-8505-9ce79b4ddbbc",
         "name": "Commercially/publicly available tools",
         "options": [{
                   "id": "fa2901d4-0b60-4809-8901-7f737a73a766",
                   "name": "BFC – Biodiversity Footprint Calculator",
                   "isOther": false
                   }
                ]
             }
          ], 
          "status": “ANSWERED”,
      }
}
 

Response

JSON Response Schema – Success

The following message will be displayed on successful updating of the content.


{
"responseVersion": integer
}

JSON Response Schema – Client Error

The following message will be displayed on unsuccessful updating of the content.

Note: If any part of the update fails, then the whole update will be rejected and no changes would occur in the CDP Portal.


{
"message": "string",
"questionId": "string",
"responseContent": {}
"statusCode": 0,
"error": "string",
"minDate": "string",
"maxDate": "string",
"textLength": 0,
"textMaxLength": 0,
"maxDecimals": 0,
"minValue": 0,
"maxValue": 0,
"invalidOptions": {},
"dataTypeErrors": {}
}


As much as possible the error messages will direct you to where the issue was found in the provided PUT request body.

Error Handling

1. Invalid Subscription Key ID

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 incorrect or invalid organization key is entered, the following error is displayed:
 

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

3. Invalid questionId

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

{
"message": "Question does not exist",
"questionId": "1",
"statusCode": 400,
"error": “Bad Request”
}

4. Previous Year Questions

When a previous questionId is used, the following error is displayed:
 

{
"message": "Questionnaire is closed",
"statusCode": 409,
"error": "The questionnaire is closed, unable to process"
}

5. Invalid Status

When an incorrect or invalid answer status is entered, the following error is displayed:
 

{
"message": [

                    "updateResponseInput.status must be one of the following values: UNANSWERED, ANSWERED, SKIPPED, PROGRESS, REVIEWED, CONDITIONAL",
             ],

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

6. Non-Editable Response

When the response is in a non-editable state (submitted), the following error is displayed:
 

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

7. Invalid SINGLE_SELECT option

When an incorrect or invalid Option Id or name is entered, the following error is displayed:
 

{
"message": "Invalid option is selected.",
"questionId": "20eb23ce-6316-43fa-8e7a-6eaee7d5b615",
     "responseContent": {
         "id": "68a11cd1-2c08-4cf8-9e42-8586fa9dd086",
         "name": "Latin American Spanish",
         "isOther": false
            } ,
                "statusCode": 400,
              "error": “Bad Request”
}

8. Invalid Option - MULTI_SELECT

When an incorrect or invalid option ID is entered for the specified question, the following error is displayed:
 

{
"message": "Invalid options are selected.",
"questionId": "ab565104-39b7-453c-a4a0-adc4b249c904",
     "responseContent": [
{
         "id": "5f6d9d1e-8684-4b75-a6ac-9b738af73ef2",
         "name": "Afghanistan",
         "isOther": false
            }, 
            {
         "id": "3802bb82-1161-4bd1-9f61-27aeec37c065",
         "name": "Åland Islands",
         "isOther": false
             }
          ], 
           "invalidOptions": [
             {
         "id": "3802bb82-1161-4bd1-9f61-27aeec37c065",
         "name": "Åland Islands",
         "isOther": false
      }
],
                "statusCode": 400,
              "error": “Bad Request”
}

9. Invalid Numerical Input

When an incorrect numeric value is entered based on the validation rules of the question, the following error is displayed:
 

{
"message": "Number should be less than or equal to the maximum allowed value.",
"questionId": "63379134-1ac4-4eb0-b237-522968486e95",
"responseContent": 100.1332,
"maxValue": 90,
"statusCode": 400,
"error": "Bad Request",
}
 

When an invalid numeric value is entered, the following error is displayed:
 

{
"message": "Invalid number",
"questionId": "63379134-1ac4-4eb0-b237-522968486e95",
"responseContent": "100.. 12",
"statusCode": 400,
"error": "Bad Request",
}

10. Invalid/Incorrect Date

When an incorrect or invalid date value is entered based on the validation rules of the questions, the following errors is displayed:
 

{
"message": "Selected date exceeds the latest allowable date.",
"questionId": "48f3dc87-6c20-4188-818b-55e89c9507bc",
"responseContent": "2027-03-20T23:00:00.000Z",
"maxDate": "2024-10-15T23:00:00.000Z",
"statusCode": 400,
"error": "Bad Request",
}
{
"message": "Invalid date",
"questionId": "48f3dc87-6c20-4188-818b-55e89c9507bc",
"responseContent": "2023-03-20T23:00:00.00a0Z",
"statusCode": 400,
"error": "Bad Request",
}

11. Invalid/Incorrect Matrix Row ID

When an incorrect or invalid matrix row id value is entered for the specified question, the following error is displayed:
 

{
"message": "Row does not exist.",
"questionId": "48f3dc87-6c20-4188-818b-55e89c9507bc",
"responseContent": null,
            "rowId": "78abe0ca-d273-4d74-8591-0b4b52d534d31",
            "statusCode": 400,
            "error": "Bad Request",
}

12. Invalid/Incorrect GROUPED_OPTIONS value

When an incorrect or invalid values are entered, the following errors is displayed:
 

{
"message": "Invalid options are selected.",
"questionId": "311852a5-e609-4a93-b6c4-ef5ffd9858aa",
"respoonseContent": [
   {
         "group": "6e7a43d2-d525-4f77-9a14-efa7cfd0afc1e",
         "name": "Commercially/publicly available tools",
         "options": [
        {
                   "id": "858831f0-a25d-410c-a12b-6103d85bf8cc",
                   "name": "BFC – Biodiversity Footprint Calculator",
                   "isOther": false
                   }
                ]
             }
          ], 
          "invalidOptions": [
                   {
                   "id": "858831f0-a25d-410c-a12b-6103d85bf8cc",
                   "name": "BFC – Biodiversity Footprint Calculator",
                   "isOther": false
      }
],
                "statusCode": 400,
              "error": “Bad Request”
}

13. URL Error

When a URL is entered as a part of the update response, the following error is displayed. The API currently doesn't support URL links due to security reasons.
 

{
"message": "URL is not allowed.",
"questionId": "87e4ae80-a1e1-439a-b3b3-1a503d27e97c",
"responseContent": "https://myportal.cdp.net/",
"statusCode": 400,
"error": "Bad Request",
}
 

14. General Error

When multiple updates are sent for a single question in a single Json update, it will result in an error. Only singular updates per question is allowed.
 

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

POST/DELETE Requests

POST requests are not implemented for this endpoint, as updates can only be made against an existing response.

DELETE requests are not implemented for this endpoint, preventing deletion of a Discloser’s response data. 


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