Examples of POST

Use the POST method to create new objects and to execute Analytics reports. To create new instances (that is, objects) of resources, such as incidents, use the following URL syntax with the POST method:

https://your_site_interface/services/rest/connect/version/resource

For related examples, see:

Simple Example

Using POST with the following URI:

https://mysite.example.com/services/rest/connect/v1.4/incidents

with the following body:

{
"primaryContact":
    {
    "id": 2
    },
"subject": "FishPhone not working"
}

returns the following incident data:

{
    "id": 32,
    "lookupName": "150403-000006",
    "createdTime": "2015-04-03T17:55:45.000Z",
    "updatedTime": "2015-04-03T17:55:45.000Z",
    "asset": null,
    "assignedTo": {
        "account": null,
        "staffGroup": null
        },

    ...

    "primaryContact": {
        "links": [
        {
            "rel": "self",
            "href": "https://mysite.example.com/services/rest/connect/v1.4/contacts/2"
            },
        {
            "rel": "canonical",
            "href": "https://mysite.example.com/services/rest/connect/v1.4/contacts/2"
            },
        {
            "rel": "describedby",
            "href": "https://mysite.example.com/services/rest/connect/v1.4/metadata-catalog/contacts"
            }
        ]
    },

    ...

    "subject": "FishPhone not working",
    "threads": {
        "links": [
        {
            "rel": "self",
            "href": "https://mysite.example.com/services/rest/connect/v1.4/incidents/32/threads"
            }
        ]
    },
    "links": [
    {
        "rel": "self",
        "href": "https://mysite.example.com/services/rest/connect/v1.4/incidents/32"
        },
    {
        "rel": "canonical",
        "href": "https://mysite.example.com/services/rest/connect/v1.4/incidents/32"
        },
    {
        "rel": "describedby",
        "href": "https://mysite.example.com/services/rest/connect/v1.4/metadata-catalog/incidents"
        },
    {
        "rel": "alternate",
        "href": "https://mysite.example.com/services/rest/connect/v1.4/incidents/32",
        "mediaType": "application/schema+json"
        }
    ]
}

Complex Example

You can use the POST operation with more complex data, such as the following request, which uses the same URI to create an incident as in simple example:

{
    "asset": {
              "id": 1
            }, 
    "assignedTo": {
        "account": {
            "id": 2
            },
        "staffGroup":{
            "id": 100001
            }
        },
    "banner": {
        "importanceFlag": {
            "lookupName": "Medium"
            },
        "text": "banner text"
        },
    "billedMinutes": [
        {
        "account": {
            "id": 1
            },
        "billableTask": {
            "id": 1
            },
        "billTime": "2014-10-03T02:07:38.000Z",
        "comment": "comment 01",
        "minutes": 120
        },
        {
        "account": {
            "id": 2
            },
        "billableTask": {
            "id": 1
            },
        "billTime": "2014-11-04T12:07:15.000Z",
        "comment": "comment 02",
        "minutes": 180
        }
        ],
    "category": {
        "id": 158
        },
    "customFields": {
        "CO": {
            "ca_ic_text": "sample text",
            "ca_ic_date": "2014-02-03",
            "ca_ic_time": "2014-10-03T02:07:38.000Z",
            "ca_ic_integer": 10
            }
        },
    "otherContacts": [
        {
        "lookupName": "Fred Flintstone"
        },
        {
        "id": 2
        }
        ],
    "primaryContact": {
        "lookupName": "Barney Rubble"
        },
    "language": {
        "lookupName": "en_US"
        },
    "organization": {
        "lookupName": "AAA"
        },
    "responseEmailAddressType": {
        "id": 0
        },
    "severity": {
        "id": 1
        },
    "statusWithType": {
        "status": {
            "id": 2
            }
        },
    "subject": "Can I pay my phone bill online?",
    "threads": [
        {
        "entryType": {
            "lookupName": "Customer"
            },
        "channel": {
            "id": 2
            },
        "contact": {
            "id":12  
            },
        "text": "contact entry"
        },
        {
        "entryType": {
            "id": 1
            },
        "channel": {
            "lookupName": "Phone"
            },
        "text": "note entry"
        }
        ]
}