# Copy QuestionSet

## This API is associated with copying questionset on the Sunbird Platform.

<mark style="color:green;">`POST`</mark> `/questionset/v1/copy/{QuestionSet_Id}`

• The endpoint for **Copy QuestionSet** is <mark style="color:orange;">/questionset/v1/copy</mark>\
• It points to inquiry-api-service (assessment service) - <mark style="color:orange;">/questionset/v4/copy</mark> \
• You need to provide a valid Question Set Id value in <mark style="color:orange;">{</mark>QuestionSet\_Id<mark style="color:orange;">}</mark> field of the API URL.\
• All parameters marked with <mark style="color:red;">\*</mark> are mandatory. You must provide values for these parameters. \
• 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 Request URL |

#### Headers

| Name                                            | Type   | Description                                                                                                                                                                                                                                                |
| ----------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | The Content-Type entity is the media type of the resource. The possible media types can be: <mark style="color:green;">Application/json</mark>                                                                                                             |
| Authorization<mark style="color:red;">\*</mark> | String | <p>You require authorization to make use of the API. Raise a request to the administrator for the use of the API. You will receive the authorization key. Specify the key received, here.<br>Set <mark style="color:green;">Bearer {{api\_key}}</mark></p> |
| x-channel-id                                    | String | Unique identification number associated with a root organisation.                                                                                                                                                                                          |

#### Request Body

| Name                                      | Type   | Description                                                                        |
| ----------------------------------------- | ------ | ---------------------------------------------------------------------------------- |
| request<mark style="color:red;">\*</mark> | Object | The body is the representation of the resource object for importing a question set |

{% tabs %}
{% tab title="200: OK The Copy QuestionSet operation was successful!" %}

```javascript
{
    "id": "api.questionset.copy",
    "ver": "3.0",
    "ts": "2023-06-23T06:41:31ZZ",
    "params": {
        "resmsgid": "8bba3dda-f81e-4659-8c05-55caed20d174",
        "msgid": null,
        "err": null,
        "status": "successful",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "node_id": {
            "do_2138240203066900481600": "do_2138240204082216961601"
        },
        "versionKey": "1687502491400"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request The Copy QuestionSet operation failed. You may have missed providing input for a mandatory parameter.'" %}

```javascript
{
    "id": "api.questionset.copy",
    "ver": "3.0",
    "ts": "2023-06-23T06:44:12ZZ",
    "params": {
        "resmsgid": "2ea62aa3-f2a9-4aeb-86f0-9d648591d1f2",
        "msgid": null,
        "err": "ERR_BAD_REQUEST",
        "status": "failed",
        "errmsg": "Hierarchy data is empty"
    },
    "responseCode": "CLIENT_ERROR",
    "result": {
        "messages": null
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error We track these errors automatically and try to set it right at the earliest." %}

```javascript
{
  "id": "api.questionset.copy",
  "ver": "3.0",
  "ts": "2020-12-10T08:51:51.647Z",
  "params": {
    "resmsgid": "f234a6f0-3ac4-11eb-b0a2-8d5c9f561887",
    "msgid": null,
    "status": "failed",
    "err": null,
    "errmsg": null
  },
  "responseCode": "SERVER_ERROR",
  "result": {}
}
```

{% endtab %}

{% tab title="404: Not Found The Copy QuestionSet operation failed. You may have requested a resource that is not existing in the server.'" %}

{% endtab %}
{% endtabs %}

#### Sample Request

```json
{
  "request": {
    "questionset": {
      "createdBy": "User001",
      "createdFor": [
        "Sunbird"
      ],
      "name": "Sunbird-QS"
    }
  }
}
```

#### Request schema

<table><thead><tr><th width="139.33333333333331">Attribute</th><th width="486">Description</th><th>Type</th></tr></thead><tbody><tr><td>createdBy</td><td>Represents the the user who triggered the copy operation</td><td>string</td></tr><tr><td>createdFor</td><td>Represents the organization on behalf the request was triggered</td><td>Object</td></tr><tr><td>name</td><td>Represents the collection with which Questionset can be copied.</td><td>string</td></tr></tbody></table>

#### Success result schema

| Attribute | Type            | Description               |
| --------- | --------------- | ------------------------- |
| node\_id  | Array of Object | Node Ids that were copied |

**cURL**

```
curl --location -g --request POST '{{host}}/questionset/v1/copy/{QuestionSet_Id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_key}}' \
--header 'X-Channel-Id: {{channel_id}}' \
--data-raw '{
  "request": {
    "questionset": {
      "createdBy": "User001",
      "createdFor": [
        "Sunbird"
      ],
      "name": "Sunbird-QS"
    }
  }
}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://inquiry.sunbird.org/learn/product-and-developer-guide/question-and-question-set-service/apis/v1/questionset-apis/copy-questionset.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
