HTTP POST example

Below is an example of an HTTP POST call to the contentmanagement.createProject API.

In a POST request, method parameters can be sent as:

  • query string key-value pairs

  • JSON object in the request body

  • a mix of both.

object type parameters cannot be represented as a query string element and therefore must be sent in the request body. The following examples show both approaches.

Using the query string

$ API=https://manager.example.com/rhn/manager/api
$ curl -H "Content-Type: application/json" --cookie "pxt-session-cookie<tokenhash>;" -X POST \
> "$API/contentmanagement/createProject?projectLabel=myproject&name=My%20Project&description="
{
  "success": true,
  "result": {
    "name": "My Project",
    "id": 1,
    "label": "myproject",
    "orgId": 1
  }
}

Using the request body

The request body must be a top-level JSON object that contains all the parameters as its properties.

$ API=https://manager.example.com/rhn/manager/api
$ curl -H "Content-Type: application/json" --cookie "pxt-session-cookie<tokenhash>;" \
> -d '{"projectLabel":"myproject","name":"My Project","description":""}' \
> $API/contentmanagement/createProject
{
  "success": true,
  "result": {
    "name": "My Project",
    "id": 1,
    "label": "myproject",
    "orgId": 1
  }
}