پرش به مطلب اصلی

Edit News API

POST /editNews

Description

This API endpoint allows an admin to edit an existing news item by providing the news item's unique identifier and the updated details such as title, description, email notification preference, and associated roles.

Request Body

The request utilizes GraphQL to perform the editNews mutation.

Mutation:

mutation editNews ($id: Int!, $news: NewsEdit) {
editNews (id: $id, news: $news) {
id
title
description
notifyByEmail
createdAt
updatedAt
}
}

Variables:

{
"id": 0,
"news": {
"title": "<News_Title>",
"description": "<News_Description>",
"notifyByEmail": true,
"roles": [
0
]
}
}
  • id (Int): The unique identifier of the news item to be edited.
  • news (NewsEdit Object): An object containing the updated details of the news item.
    • title (String): The updated title of the news item.
    • description (String): The updated 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 update is successful, the response will return the updated details of the news item, including its ID, title, description, and creation timestamps.
    {
    "data": {
    "editNews": {
    "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 news ID, missing required fields, or server errors.

Note:

Ensure that the id corresponds to an existing news item within the platform and that the news object contains valid and correctly formatted data. This API should be used by admins with the necessary permissions to manage and update news items linked to specific roles within the platform.