# Update QuestionSet

## This API is used to update an existing question set on the Sunbird-inQuiry Platform.

<mark style="color:purple;">`PATCH`</mark> `/questionset/v2/update/{questionSet_id}`

• <mark style="color:orange;">/Update/</mark> endpoint executes the "Update QuestionSet" request based on parameters provided as metadata in the request body.\
• It points to inquiry-api-service (assessment service) - <mark style="color:orange;">/questionset/v5/update</mark>\
• It is mandatory to provide values for parameters marked with <mark style="color:red;">\*</mark>. \
• Mandatory fields cannot be null or empty.

#### Path Parameters

| Name                                              | Type   | Description                                        |
| ------------------------------------------------- | ------ | -------------------------------------------------- |
| questionSet\_id<mark style="color:red;">\*</mark> | String | Append a valid QuestionSet ID to the requested URL |

#### Headers

| Name                                            | Type   | Description                                                                                                                                                                                                                     |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | The Content-Type entity is the media type of the resource. Possible media types can be:-<mark style="color:green;">Application/json</mark>                                                                                      |
| Authorization<mark style="color:red;">\*</mark> | String | <p>All question APIs require authorization for use. Specify the authorization key received from the administrator when placing the request for use of the API.<br>Set <mark style="color:green;">Bearer {{api\_key}}</mark></p> |
| x-channel-id                                    | String | Unique identification number associated with a root organization.                                                                                                                                                               |

#### Request Body

| Name                                      | Type   | Description                                               |
| ----------------------------------------- | ------ | --------------------------------------------------------- |
| request<mark style="color:red;">\*</mark> | Object | It contains metadata about the questionset to be updated. |

{% tabs %}
{% tab title="200: OK The Update Question Set operation was successfuly executed." %}

```javascript
{
  "id": "api.questionset.update",
  "ver": "5.0",
  "ts": "2023-06-29T07:51:03ZZ",
  "params": {
    "resmsgid": "9d9d4824-cc40-4ac7-a3d6-6da61c0240e9",
    "msgid": null,
    "err": null,
    "status": "successful",
    "errmsg": null
  },
  "responseCode": "OK",
  "result": {
    "identifier": "do_113207924037746688110",
    "versionKey": "1612295707004"
  }
}
```

{% endtab %}

{% tab title="400: Bad Request The 'Update QuestionSet' operation failed ! The possible reason for failure is that you may have missed providing input for a mandatory parameter." %}

```javascript
{
  "id": "api.questionset.update",
  "ver": "5.0",
  "ts": "2023-06-29T07:51:03ZZ",
  "params": {
    "resmsgid": "fcfcf6d6-84f1-43f5-b573-c3b6cf69ef53",
    "msgid": null,
    "err": "CLIENT_ERROR",
    "status": "failed",
    "errmsg": "Invalid version Key"
  },
  "responseCode": "CLIENT_ERROR",
  "result": {
    "messages": null
  }
}
```

{% endtab %}

{% tab title="404: Not Found The Update Question Set operation failed !The possible reason for failure is that you may have provided wrong question ID." %}

```javascript
{
  "id": "api.questionset.update",
  "ver": "5.0",
  "ts": "2023-06-29T07:51:03ZZ",
  "params": {
    "resmsgid": "2b139ee9-f091-4cca-b466-32af45f49a65",
    "msgid": null,
    "err": "NOT_FOUND",
    "status": "failed",
    "errmsg": "Error! Node(s) does not exist. | [Invalid Node Id.]: do_1132079240377466881101"
  },
  "responseCode": "RESOURCE_NOT_FOUND",
  "result": {
    "messages": null
  }
}
```

{% endtab %}

{% tab title="500: Internal Server Error Looks like something went wrong! These errors are tracked automatically" %}

```javascript
{
  "id": "api.questionset.update",
  "ver": "5.0",
  "ts": "2023-06-29T07:51:03ZZ",
  "params": {
    "resmsgid": "f234a6f0-3ac4-11eb-b0a2-8d5c9f561887",
    "msgid": null,
    "status": "failed",
    "err": null,
    "errmsg": null
  },
  "responseCode": "SERVER_ERROR",
  "result": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

```json
{
  "request": {
    "questionset": {
      "description": "Updated description",
      "versionKey": "1612295414767"
    }
  }
}
```

#### Request schema

<table><thead><tr><th width="168">Attribute</th><th width="111">Type</th><th width="353">Description</th><th>Required</th></tr></thead><tbody><tr><td>versionKey</td><td>String</td><td>Represents the transaction update version key of the Questionset</td><td>Yes</td></tr><tr><td>description</td><td>String</td><td>Represents the description of the Questionset</td><td>No</td></tr></tbody></table>

#### Success result schema

| Attribute  | Type   | Description                     |
| ---------- | ------ | ------------------------------- |
| identifier | String | Unique Question identifier      |
| versionKey | String | Unique version key for question |

####

#### cURL

```shell
curl --location -g --request PATCH '{{host}}/questionset/v2/update/{{questionSet_id}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_key}}' \
--data-raw '{
  "request": {
      "questionset":{
        "versionKey": {{versionKey}},
        "description": "Updated description"
      }
  }
}'
```
