Create News API
POST /createNews
Description
This API endpoint allows an admin to create a new news item by providing details such as title, description, email notification preference, and associated roles. The news can then be distributed to specific roles within the platform.
Request Body
The request utilizes GraphQL to perform the createNews
mutation.
Mutation:
mutation createNews ($news: NewsEdit) {
createNews (news: $news) {
id
title
description
notifyByEmail
createdAt
updatedAt
}
}
Variables:
{
"news": {
"title": "<News_Title>",
"description": "<News_Description>",
"notifyByEmail": true,
"roles": [
0
]
}
}
- news (NewsEdit Object): An object containing the details of the news item to be created.
- title (String): The title of the news item.
- description (String): A description or content of the news item.
- notifyByEmail (Boolean): A flag indicating whether to notify users by email.
- roles (List of Int): A list of role IDs that are associated with this news item.
Response:
-
Success (200 OK):
- If the news creation is successful, the response will return the details of the newly created news item, including its ID, title, description, and creation timestamps.
{
"data": {
"createNews": {
"id": "<News_ID>",
"title": "<News_Title>",
"description": "<News_Description>",
"notifyByEmail": "<Notify_By_Email>",
"createdAt": "<Creation_Timestamp>",
"updatedAt": "<Update_Timestamp>"
}
}
} -
Error (4XX/5XX):
- Appropriate error messages and status codes will be returned in cases of invalid data, missing required fields, or server errors.
Note:
Ensure that all required fields for the news
object are provided and correctly formatted according to the platform's specifications. This API should be used by admins with the necessary permissions to create and distribute news items linked to specific roles within the platform.