# Publish Question

## This API is used to publish the question on Sunbird-inQuiry platform.

<mark style="color:green;">`POST`</mark> `/question/v2/publish/{question_id}`

• <mark style="color:orange;">/publish</mark> endpoint executes the "Publish Question" request based on parameters provided       as metadata in the request body\
• It points to inquiry-api-service (assessment service)- <mark style="color:orange;">/question/v5/publish</mark>\
• You need to provide a valid Question Id value in <mark style="color:orange;">{question\_id}</mark> field of the API URL.\
• It is mandatory to provide values for parameters marked with <mark style="color:red;">\*</mark>.\
• Mandatory fields cannot be null or empty.\
• <mark style="color:orange;">Asynchronous flink job : async-questionset-publish will takes care of the publishing activity.</mark>

#### Path Parameters

| Name                                           | Type   | Description                                   |
| ---------------------------------------------- | ------ | --------------------------------------------- |
| question\_id<mark style="color:red;">\*</mark> | String | Append a valid Question 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. It should be <mark style="color:green;">Application/json</mark>                                                                                                                                      |
| Authorization<mark style="color:red;">\*</mark> | String | <p>To make use of the API, you require authorization. Raise a request to the administrator, for the use of the API. You will receive the authorization key. Specify the key received, here.</p><p>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 | Object | metadata about the question to be published |

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

```javascript
{
  "id": "api.question.publish",
  "ver": "5.0",
  "ts": "2023-06-29T04:01:05ZZ",
  "params": {
    "resmsgid": "9c64cc9c-bed5-44c7-85bf-4918c3a42f58",
    "msgid": null,
    "err": null,
    "status": "successful",
    "errmsg": null
  },
  "responseCode": "OK",
  "result": {
    "message": "Question is successfully sent for Publish",
    "identifier": "do_2138282512518184961525"
  }
}
```

{% endtab %}

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

```javascript
{
  "id": "api.question.publish",
  "ver": "5.0",
  "ts": "2023-06-29T04:01:05ZZ",
  "params": {
    "resmsgid": "b084af8b-706b-4079-8ec2-0beb0753931c",
    "msgid": null,
    "err": "NOT_FOUND",
    "status": "failed",
    "errmsg": "Error! Node(s) doesn't Exists. | [Invalid Node Id.]: do_213828251251818496152"
  },
  "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.question.publish",
  "ver": "5.0",
  "ts": "2023-06-29T03:37:12ZZ",
  "params": {
    "resmsgid": "f234a6f0-3ac4-11eb-b0a2-8d5c9f561887",
    "msgid": null,
    "status": "failed",
    "err": null,
    "errmsg": null
  },
  "responseCode": "SERVER_ERROR",
  "result": {}
}
```

{% endtab %}

{% tab title="400: Bad Request The Publish Question operation failed." %}

```javascript
{
    "id": "api.question.publish",
    "ver": "5.0",
    "ts": "2023-06-29T06:09:24ZZ",
    "params": {
        "resmsgid": "a070ec5e-75c3-46b2-8cf8-e4feda03e042",
        "msgid": null,
        "err": "ERR_OBJECT_VALIDATION",
        "status": "failed",
        "errmsg": "Mandatory Fields [body, responseDeclaration, interactions, outcomeDeclaration] Missing for do_2138282512518184961525"
    },
    "responseCode": "CLIENT_ERROR",
    "result": {
        "messages": null
    }
}
```

{% endtab %}
{% endtabs %}

#### Success result schema

| Attribute  | Type   | Description                |
| ---------- | ------ | -------------------------- |
| identifier | String | Unique Question identifier |
| message    | String | Publish success message    |

#### cURL

```shell
curl --location -g --request POST '{{host}}/question/v2/publish/{{question_id}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_key}}' \
--header 'X-Channel-Id: {{channel_id}}' \
--data-raw '{
    "request": {}
}'
```


---

# 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/v2/question-apis/publish-question.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.
