Create File API
POST /createFile
Description
This API endpoint allows an admin to create a new file by providing details such as title, description, URL, and associated roles. The file can then be linked to specific roles within the platform.
Request Body
The request utilizes GraphQL to perform the createFile
mutation.
Mutation:
mutation createFile ($file: FileEdit) {
createFile (file: $file) {
id
title
description
url
}
}
Variables:
{
"file": {
"title": "<File_Title>",
"description": "<File_Description>",
"url": "<File_URL>",
"roles": [
0
]
}
}
- file (FileEdit Object): An object containing the details of the file to be created.
- title (String): The title of the file.
- description (String): A description of the file.
- url (String): The URL where the file is hosted or can be accessed.
- roles (List of Int): A list of role IDs that are associated with this file.
Response:
-
Success (200 OK):
- If the file creation is successful, the response will return the details of the newly created file, including its ID, title, description, and URL.
{
"data": {
"createFile": {
"id": "<File_ID>",
"title": "<File_Title>",
"description": "<File_Description>",
"url": "<File_URL>"
}
}
} -
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 file
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 manage files linked to specific roles within the platform.