POST /content/{path}

Adds a single file of new content to the platform, or adds a new directory.

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: Must be logged in. API Admin or other authorized user.

This topic includes the following sections:

HTTP Method

POST

URL

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

Sample Request

Request URL #1: Creating a new folder with empty table of contents file

The example below creates a new folder named assets with a file in it, named toc.apiversion20693.acmepaymentscorp.json, the JSON table of contents file for the new folder. The file contains a single pair of curly braces (encoded in Sample request body (request URL #1) below).

https://api.acmepaymentscorp.com/content/api/api18969.acmepaymentscorp/documents/assets/toc.apiversion20693.acmepaymentscorp.json?body=%7B%7D

Request URL #2: Creating an API legal agreement

The example below creates a new legal agreement for an API, with very simple text.

https://api.acmepaymentscorp.com/content/api/0af593d7-6a4f-47ed-a058-4e1f77b26dab.acmepaymentscorp/legal/eula.txt?body=End+user+license+agreement

Request URL #3: Publishing an API legal agreement

The example below publishes a legal agreement for an API by updating the JSON TOC (table of contents) file in the folder. The legal agreement must already exist. The URL and message body update the TOC. For the body content, see Sample request body (request URL #3) below.

https://acmepaymentscorp.apiportal.com/content/api/1254cc85-f5a7-4dfc-aa98-c0a2ec258dae.acmepaymentscorp/
legal/toc.ff46365a-ebac-4fd3-9cbd-f1ac20262f80.acmepaymentscorp.json

Request URL #4: Adding a SimpleDev documentation folder

The example below creates the documentation folder for a corresponding SimpleDev theme.

http://acmepaymentscorp.com/content/documentation

Sample request headers

POST /content/api/api18969.acmepaymentscorp/documents/assets/toc.apiversion20693.acmepaymentscorp.json HTTP/1.1
Host: {hostname}
Accept: */*
Content-Type: application/x-www-form-urlencoded
X-Csrf-Token_acmepaymentscorp: TokenID%3D8ed70a13-8469-11e8-b37a-b155e4eabeb8%2CexpirationTime%3D153...

Sample request body (request URL #1)

body=%7B%7D

Sample request body (request URL #3)

The request body updates the folder table of content to reflect the fact that the API legal agreement has been published, and is now ready to be activated. The request body must be URL-encoded.

body=%7B%22toc%22%3A%5B%22api_legal_agreement_acmepaymentscorp.txt%22%2C%22api_legal_agreement_acmepaymentscorp2.txt%22%5D%2C%22sequence%22%3A%5B%22api_legal_agreement_acmepaymentscorp.txt%22%2C%22api_legal_agreement_acmepaymentscorp2.txt%22%2C%22toc.ff46365a-ebac-4fd3-9cbd-f1ac20262f80.acmepaymentscorp.json%22%5D%2C%22displayNames%22%3A%7B%7D%7D

Sample request body (request URL #4) in Postman

The example below creates the help folder for a corresponding SimpleDev theme, in Postman. In this example, CSRF is turned off, so only the content-type header is required. The path path parameter and folder form parameters are used.

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

Request Headers

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

Header Description
Accept Not applicable.
Content-Type application/x-www-form-urlencoded
Cookie AtmoAuthToken_{fedmemberid}={cookie value, which usually starts with TokenID}—The platform cookie. This is the Akana API Platform authorization token, and must be sent with every API request that requires login. For more information and an example, see Session cookies.
X-Csrf-Token_{fedmemberID} The CSRF prevention header; may or may not be required, depending on platform settings. See CSRF Prevention on the Platform. By default, the CSRF header is not required for GET operations and is required for all others, with a few exceptions relating to user login.

Request Parameters

Parameter Parm Type Data Type Required Description
body Form string Required The contents for the new file, URL-encoded. For example, for an empty JSON table of contents file in a new empty directory, this parameter would be body=%7B%7D which adds an empty set of curly braces for the empty JSON file.
type Form string Optional The type of content. Use a valid media type as a value for this attribute; for example, html or json. If not specified, the operation uses the file extension to determine the media type.
path Path string Required The path and filename for the location where you want to store the new content that you're adding. The path must be valid for your API resources. You choose the filename in the same way that you would when creating a file in your local file system.
folder Form Boolean Optional Indicates whether the operation is adding a folder. Default: false.

Response

If successful, this operation returns HTTP status code 200 with no content.

Sample Response

The sample response below shows successful completion of this operation.

Sample response headers

HTTP/1.1 200 OK
Content-Type: text/html
Date: Tue, 1 Jul 2014 20:00:00 GMT

Sample response body

None. However, note that if you are running the API in a browser the HTTP code is returned in an HTML wrapper. For more information, see File Upload with Ajax.

Response Headers

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

Header Description
Content-Type text/html

Response Body

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

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. You would also get this response for any operation that requires login (almost all) if the login cookie was missing.
500 An error occurred processing the call.

More information about Akana API Platform API error messages.