Object Format

This article gives general information about object format for resources.

Accessing resource objects using REST APIs returns a JSON representation of the object's data. When you create or update resource objects, some properties are automatically added. For example, ID or datetime fields (wherever applicable). Please refer to the documentation of the resource for details.

Please note that HRCloud allows customization of resource objects. The fields explained in this documentation are generic fields of the resource. Please contact us for custom fields in different resource objects. 

Create Objects

To create a new object, send a POST request to the resource URL. Pass the values for the fields as a JSON object in the request body. Any fields for which the values are not specified in the request body are by default set to Null. Success or failure of the request is defined by the response status code. 

Bulk Create

The POST method supports operations on multiple records using a single request.

The payload is similar to that used when adding a single record, except that you must add enclosing square brackets [] to send multiple records. 

For example : The following sample creates two divisions.

Request:

POST https://corehr-api.hrcloud.com/v1/cloud/xDivision

Message body:

  [ 
{

"xDivisionName": "Sales Training",
"xDivisionCode": "ST1",
"xRecordStatus": "Active"
},
{
"xDivisionName": "Customer Support Training",
"xDivisionCode": "CST1",
"xRecordStatus": "Active"
}
]

Response

Status: 200 OK

Retrieve Objects

To retrieve contents of an object, send a GET request to the object URL. The response body is a JSON object containing the status code and the object information requested.

Multiple selection fields

You can define a cloud object using single and/or multiple selection fields.

For example, Gender is a single selection field, and Languages is a multiple selection field in the following response:

{
"Id": "8320fb07077a2935",
"Gender": "Female",
"Languages": "C#, Java, Python",
"xEmployeeLookup": {
"Id": "daa66d64c17edff246c2bd88c338b8c1",
"xFirstName": "Angie",
"xMIddleName": "",
"xLastName": "Nedde",
"xEmployeeNumber": "101202",
"xStartDate": "04/15/2015",
"xEmail": "angne@somer.com",
"xFullName": "Angie Nedde",
"__ObjectName": "xEmployee",
"__Self": "https://corehr-api.hrcloud.com/v1/cloud/xEmployee/daa66d64c17edff246c2bd88c338b8c1",
}
}

During the creation of new objects(using POST) or updation of an object( using PUT), the payload values for these fields are validated against those defined in the dashboard.

For multiple selection fields, the values appear in a comma-separated list, for example:

"Languages": "C#, Java, Python"

Update Objects

To update the data for an object that already exists, send a PUT request to the object URL. Any properties not specified in the request object, remain unchanged.

The response body is a JSON object containing the status information and the updated object.

Identifying records for update

When using the PUT method to update entities, there are two ways to select the record:

  • Using the object ID

    For example, to update the division record with the Id '0872b9ce4ba79c26', use the following request.

    PUT https://corehr-api.hrcloud.com/v1/cloud/xDivision

    Request body

    {
    "Id": "0872b9ce4ba79c26",
    "xDivisionName": "Payroll",
    "xDivisionCode": "PAY",
    "xRecordStatus": "Active"
    }
  • Using a particular object field.
    In the method, use a field in the form of identifier as
    ?Identifier=:field_name
    This field must be a unique field in the object. In this case, the ID should not be provided in the payload.

Bulk Update

The PUT method support operations on multiple records using a single request. The payload is similar to that used when updating a single record, except:

    • You must add enclosing square brackets [ ].
    • PUT requests must include the ID.

For example, the following request updates two locations.

Request:

PUT https://corehr-api.hrcloud.com/v1/cloud/xLocation

Message body:

[
{
"Id": "3026ef36ef2412b7",
"xLocationName": "Anchorage",
"xDescription": "Operations",

},
{
"Id": "27784c8a0686092e",
"xLocationName": "Austin",
"xDescription": "Payroll",
}
]

Response:

Status: 200 OK

Delete Objects

To delete an object, send a DELETE request to its object URL.