Creating Objects

Description

The API provides the ability to create new object records via Create Actions.

NOTE: Submitting an action form via an API request may feel different compared to what you'd normally expect in other modules of the product. The API supports only the default value and mandatory options of form fields. In some cases, the API will not return an error when you submit an action form with a mandatory field not filled. It happens if the field on the form is pre-populated with either a default value or its current value in the Object's record.

HTTP method

POST

API URL
http://www.example.com/api/v2
POST parameters

POST parameters should be specified in the request’s body, in JSON format.

Parameter Description

ActionId

The Create Action ID.

NOTE: You can find the Create Action ID and a list of fields for a particular object class in the Settings App: Customization > [Module]> [Object Class] > Workflow > Templates.

Fields

Fields on the Create Action form.

<fieldName1>

<fieldName2>

...

Field names

INFO: For the correct spelling of Alloy Navigator Express field names, see Referring to Object Fields in Alloy Navigator Express API.

Field values
  • For reference fields, you must specify the identifier of the referenced object (example: PN000017), or its name (example: Angelina Reyes).

  • For classification fields (e.g. Priority or Impact), you must specify the element’s display value (example: Immediate or Multiple People).

  • For boolean fields, you must specify true/false or 1/0.

INFO: For HTML fields, you must specify text with HTML tags, see Working with HTML fields.

POST body format
{

	"ActionId": "<actionId>",

	"Fields":{

		"<fieldName1>": "<fieldValue1>",

		"<fieldName2>": "<fieldValue2>",

		...

	}

}
Response Format

On success, the server returns the identifiers of the newly created object.

{

	"success": true,

	"errorCode": 0,

	"errorText": "",

	"responseObject": {

		"Succeed": true/false,

		"ObjectID": "<Object ID>",

		"ObjectOID": "<Object OID>"

	}

}
Property Description Format

Succeed

New object record was created.

Boolean

ObjectID

Internal database identifier of the created object.

String

ObjectOID

OID of the created object.

INFO: For more information, see Identification of Objects in Alloy Navigator Express.

String

In case of a failure the server returns an error message. The following errors may appear:

Error message Description

Authorization has been denied for this request.

The Authorization header is missing or the token has expired.

This action cannot be executed because the action's condition is not satisfied.

The user is not authorized to use the Step Action.

Requested action is not available.

The Step Action with the specified ActionID was not found.

Field <name> is unknown.

The field with the specified name was not found.

Example

Here is an example of how you can create a new Asset. Call the Create Action #388 and set values for Name, Description, Type, and Associated.

Request:

(POST) http://www.example.com/api/v2

POST Body

{

	"ActionId": 388,  //"Create new asset"

	"Fields":{

		"Name":"Asset API",

		"Description":"Asset for API test",

		"Type":"Non-Physical", //classification field

		"Associated":"PC00092" // reference field

	}

}

Response:

{

	"success": true,

	"errorCode": 0,

	"errorText": "",

	"responseObject": {

		"Succeed": true,

		"ObjectID": "6a469d7d-4bb1-4896-befb-10027f1f0c61",

		"ObjectOID": "A000124"

	}

}