POST /content/{path}

Uploads a single file of existing content to the platform, or uploads a ZIP file of existing content and unzips it to the specified location.

Note: When creating or uploading content files, you can use the POST /content/{path} operation (with multipart/form-data content type) to upload a single file, or multiple files in a ZIP. You can use the POST /content/{path} operation (with application/x-www-form-urlencoded content-type) to create a new folder with a default JSON table of contents file in it, as in the example below, or to create a new file. If you are creating a new file, it cannot be empty; you must include the file contents in the payload, and must use the application/x-www-form-urlencoded content type.

Authorization Roles/Permissions: API Admin or other authorized user.

This topic includes the following sections:

HTTP Method

POST

Back to top

URL

https://{hostname}/content/{path}

Back to top

Sample Request

The example below shows a request to upload a ZIP file of content for the specified API.

Request URL #1

Uploads an API documentation ZIP file and unzips it.

https://api.acmepaymentscorp.com/content/api/api19427.acmepaymentscorp/documents?unpack=true&wrapInHTML=true

Request URL #2

https://api.acmepaymentscorp.com/content/help?unpack=true

Sample request headers

POST /content/api/api19427.acmepaymentscorp/documents?unpack=true&wrapInHTML=true HTTP/1.1
Host: {hostname}
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
X-Csrf-Token_acmepaymentscorp":"TokenID%3D8ed70a13-8469-11e8-b37a-b155e4eabeb8%2CexpirationTime%3D153...

Sample request body

The request body is the ZIP file.

Sample request #2 in Postman

In the example below, the content being uploaded is a ZIP file to be placed in the content/help folder for display in SimpleDev theme. The index.zip file is uploaded to the content/help folder and unzipped (unpack=true parameter).

Content Upload in Postman: URL, uploaded ZIP file, successful result

Back to top

Request Headers

For general information on request header values, refer to HTTP Request Headers.

Header Description
Accept Not applicable.
Content-Type

multipart/form-data

In the form data, you must include a key of File; the value for the key is the individual file or ZIP file with the content you want to upload to the specified location, as shown above in Postman. If you're uploading a ZIP file, include the unpack=true query parameter. Refer to Sample Request #2 above.

X-Csrf-Token_{fedmemberID} The CSRF prevention header; may or may not be required, depending on platform settings. See CSRF Prevention on the Platform.

Back to top

Request Parameters

Parameter Parm Type Data Type Required Description
path Path string Required The path to the location where the content being uploaded will be unzipped and stored. The path must be valid for your API resources.
unpack Query boolean Required Indicates whether the content must be unzipped. For a ZIP file this parameter is requied and must be set to true.
InMultiPart Body multipart Required The content being uploaded. For more information, see Managing Multipart/Form-Data Uploads.

Note: For information about the wrapInHTML parameter shown in the sample request message above, see File Upload with Ajax. This is only used if you are running the API in a browser context.

Back to top

Response

If successful, this operation returns HTTP status code 200, wrapped in HTML.

Back to top

Sample Response

The sample response below shows successful completion of this operation.

Sample response headers

HTTP/1.1 200 OK
Content-Type: text/html
Content-Encoding: gzip
Date: Mon, 24 Jun 2013 19:22:21 GMT

Sample response body

<!DOCTYPE html>
<html lang="en" status="200" statusText="success">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacus elit, ornare eget luctus vel, porta id elit. 
Maecenas molestie, libero sit amet blandit faucibus, orci nisi aliquet nisi, id mollis mauris ipsum a enim. Morbi lacus velit, placerat sit amet luctus eget, 
pulvinar a massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eleifend tincidunt pellentesque. Cras eu sapien massa, vitae rutrum sapien. 
Aenean id condimentum sem. Suspendisse tempor luctus ipsum, vel metus.">
</head>
<body status="200" statusText="success">
</body>
</html>

Note: for information about the HTML wrapper shown in the sample response above, see File Upload with Ajax.

Back to top

Response Headers

For general information on response header values, refer to HTTP Response Headers.

Header Description
Content-Type text/html

Back to top

Response Body

Name Type Description
Response String The response code, wrapped in HTML.

Back to top

Error Codes/Messages

If the call is unsuccessful an error code/message is returned. One or more examples of possible errors for this operation are shown below.

Item Value
401 Unauthorized. For example, you would get this response if you didn't include the custom X-Csrf-Token_{fedmemberID} header in the request, when it was required by the platform settings; or if you included an invalid or expired value for this header.
500 An error occurred processing the call.

More information about Akana API Platform API error messages.

Back to top

Related Topics