跳到主要内容

createHtmlFile

FileWrapper createHtmlFile(folderId, CreateTextOrHtmlFileRequest)

POST /api/2.0/files/{folderId}/html

Create an HTML file

Creates an HTML file in the folder named in the route out of the markup passed as the content, and answers with the stored file. The .html extension is added to the title unless the title already ends with it, and a request carrying no content is rejected as an invalid request. createNewIfExist acts the other way round than its name reads: with true the file that already carries this title is updated, the markup replacing its content and a version appearing in its history, while with false, which is also the default, another file is created and its title made unique, as in Notes (1).html. Updating needs the existing file to be editable by the caller, so one that is locked, open in an editing session, encrypted or in Trash is left alone and a new file appears beside it instead. The caller needs the right to create files in the folder and is otherwise refused with 403. The call is mutating. To create the file in the caller's own section use POST api/2.0/files/@my/html.

Parameters​

NameInTypeDescriptionNotes
folderIdpathInteger (int32)The folder the file is created in.[required] [example: 1]
CreateTextOrHtmlFileRequestbodyCreateTextOrHtmlFileRequestThe title, the content and the collision behaviour of the new file.[required]

Responses​

Status codeDescriptionTypeResponse headers
200The created or updated HTML fileFileWrapperX-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
400The request body cannot be read or has no title or content, or the title is empty, blank or longer than 165 characters--
402The content exceeds the maximum upload size, or the file does not fit into the storage quota of the portal, the room or the user--
403The caller may not create files in this folder, or the folder is a section where files cannot be created--
404The folder does not exist--
401UnauthorizedErrorApiResponse-
429Too Many Requests.ErrorApiResponseRetry-After
500Internal Server Error.ErrorApiResponse-
502Bad Gateway. Returned by the reverse proxy, response body may be HTML and not JSON.--
503Service Unavailable. Returned by the reverse proxy, response body may be HTML and not JSON.--

Return type​

FileWrapper

Third-party storage​

For a file or folder in a connected third-party storage the identifier is a string such as sbox-42, and the call differs in these parts only:

NameInTypeDescriptionNotes
folderIdpathStringThe folder the file is created in.[required] [example: sbox-42]

Return type: ThirdPartyFileWrapper

Authorization​

Basic, OAuth2 (scopes: read, write), ApiKeyBearer, asc_auth_key, Bearer, OpenId

HTTP request headers​

  • Content-Type: application/json
  • Accept: application/json