CustomObjects resource (Data API 19.10)

Summary

Http Method Resource Description
GET /custom_objects/{object_type}/{key} Reads a global Custom Object with a given object type ID and a value for the key attribute of the object which represents its unique identifier.
PUT /custom_objects/{object_type}/{key} Creates a global Custom Object from request body. Note that an existing global Custom Object with the same key will be overwritten by this action.
DELETE /custom_objects/{object_type}/{key} Deletes a global Custom Object. If the Custom Object does not exist, this will do nothing. Note that the customization scripts are only called, if the Custom Object does exist.
PATCH /custom_objects/{object_type}/{key} Updates a global Custom Object with information from request body. Note that only mentioned attributes will be updated and the key attribute is ignored. All other attributes will be left unattended.

Read global Custom Object

Reads a global Custom Object with a given object type ID and a value for the key attribute of the object which represents its unique identifier.

Url

GET https://hostname:port/dw/data/v19_10/custom_objects/{object_type}/{key}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

CustomObject

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the Custom Object mandatory=true, minLength=1, nullable=false
object_type String the ID of the object type mandatory=true, minLength=1, nullable=false

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedKeyParameterException

value (String)

parameter (String)

If the object key must be an integer, but the path parameter has an invalid format
404 CustomObjectNotFoundException

key (String)

objectType (String)

For an unknown object key
404 ObjectTypeNotFoundException

objectType (String)

For an unknown object type ID

Sample

REQUEST:
GET /s/-/dw/data/v19_10/custom_objects/my_object_type/key_0815 HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Expires: Thu, 01-Jan-1970 00:00:00 GMT

{
  "_v" : "19.10",
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
   "_type" : "custom_object",
   "object_type":"my_object_type",
   "key_property":"key_attribute",
   "c_boolean":true,
   "c_date":"2015-02-03T00:00:00.000Z",
   "c_email":"[email protected]",
   "c_integer":42,
   "c_number":42.0,
   "c_string":"some text"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v":"19.10",
   "_type":"fault",
  "fault":
  {
    "type":"CustomObjectNotFoundException",
    "message":"No custom object with key 'key_0815' for object type 'my_object_type' was found.
  }
}

Create global Custom Object

Creates a global Custom Object from request body. Note that an existing global Custom Object with the same key will be overwritten by this action.

Url

PUT https://hostname:port/dw/data/v19_10/custom_objects/{object_type}/{key}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

CustomObject

Response Document

CustomObject

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the Custom Object mandatory=true, minLength=1, nullable=false
object_type String the ID of the object type mandatory=true, minLength=1, nullable=false

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedKeyParameterException

value (String)

parameter (String)

If the object key must be an integer, but the path parameter has an invalid format
404 CustomObjectNotFoundException

key (String)

objectType (String)

For an unknown object key
404 ObjectTypeNotFoundException

objectType (String)

For an unknown object type ID

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.data.object.beforePut

beforePut (create : CustomObject ) : Status

The function is called before the custom object is created with create document.

Parameters:
create - the create document, may be null
Returns:
a non-null Status ends the hook execution
dw.ocapi.data.object.afterPut

afterPut (customObject : CustomObject , create : CustomObject ) : Status

The function is called after the custom object was created with create document.

Parameters:
customObject - the created custom object
create - the create document, may be null
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
PUT /s/-/dw/data/v19_10/custom_objects/my_object_type/key_0815 HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8
{
   "c_boolean":true,
   "c_date":"2015-02-03T00:00:00.000Z",
   "c_email":"[email protected]",
   "c_integer":42,
   "c_number":42.0,
   "c_string":"some text"
}

# in case of success:

RESPONSE:
HTTP/1.1 201 CREATED
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Location: https://example.com/s/-/dw/data/v19_10/custom_objects/my_object_type/key_0815

{
  "_v" : "19.10",
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
  "_type" : "custom_object",
  "object_type":"my_object_type",
  "key_property":"key_attribute",
  "key_value_string":"key_0815",
  "c_boolean":true,
  "c_date":"2015-02-03T00:00:00.000Z",
  "c_email":"[email protected]",
  "c_integer":42,
  "c_number":42.0,
  "c_string":"some text"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v":"19.10",
  "fault":
  {
    "type":"ObjectTypeNotFoundException",
    "message":"No object type with ID 'my_object_type' was found."
  }
}

Delete global Custom Object

Deletes a global Custom Object. If the Custom Object does not exist, this will do nothing. Note that the customization scripts are only called, if the Custom Object does exist.

Url

DELETE https://hostname:port/dw/data/v19_10/custom_objects/{object_type}/{key}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the Custom Object mandatory=true, minLength=1, nullable=false
object_type String the ID of the object type mandatory=true, minLength=1, nullable=false

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedKeyParameterException

value (String)

parameter (String)

If the object key must be an integer, but the path parameter has an invalid format
404 ObjectTypeNotFoundException

objectType (String)

For an unknown object type ID

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.data.object.beforeDelete

beforeDelete (customObject : CustomObject ) : Status

The function is called before the custom object is removed.

Parameters:
create - the create document
Returns:
a non-null Status ends the hook execution
dw.ocapi.data.object.afterDelete

afterDelete () : Status

The function is called after the custom object was deleted.

Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
DELETE /s/-/dw/data/v19_10/custom_objects/my_object_type/key_0815 HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8
x-dw-resource-state: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5

# in case of success:

RESPONSE:
HTTP/1.1 204 OK

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v":"19.10",
  "fault":
  {
    "type":"ObjectTypeNotFoundException",
    "message":"No object type with ID 'my_object_type' was found."
  }
}

Update global Custom Object

Updates a global Custom Object with information from request body. Note that only mentioned attributes will be updated and the key attribute is ignored. All other attributes will be left unattended.

Url

PATCH https://hostname:port/dw/data/v19_10/custom_objects/{object_type}/{key}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

CustomObject

Response Document

CustomObject

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the Custom Object mandatory=true, minLength=1, nullable=false
object_type String the ID of the object type mandatory=true, minLength=1, nullable=false

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedKeyParameterException

value (String)

parameter (String)

If the object key must be an integer, but the path parameter has an invalid format
404 CustomObjectNotFoundException

key (String)

objectType (String)

For an unknown object key
404 ObjectTypeNotFoundException

objectType (String)

For an unknown object type ID

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.data.object.beforePatch

beforePatch (customObject : CustomObject , update : CustomObject ) : Status

The function is called before the custom object is updated with update document.

Parameters:
update - the update document
Returns:
a non-null Status ends the hook execution
dw.ocapi.data.object.afterPatch

afterPatch (customObject : CustomObject , create : CustomObject ) : Status

The function is called after the custom object was updated with update document.

Parameters:
customObject - the updated custom object
update - the update document
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
PATCH /s/-/dw/data/v19_10/custom_objects/my_object_type/key_0815 HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8
{
   "_resource_state" : "t9ccde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73b8h6"
   "c_boolean":true,
   "c_date":"2015-02-03T00:00:00.000Z",
   "c_email":"[email protected]",
   "c_integer":42,
   "c_number":42.0,
   "c_string":"some text"
}

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Expires: Thu, 01-Jan-1970 00:00:00 GMT
{
   "_v" : "19.10",
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
   "_type" : "custom_object",
   "object_type":"my_object_type",
   "key_property":"key_attribute",
   "c_boolean":true,
   "c_date":"2015-02-03T00:00:00.000Z",
   "c_email":"[email protected]",
   "c_integer":42,
   "c_number":42.0,
   "c_string":"some text"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v":"19.10",
  "fault":
  {
    "type":"CustomObjectNotFoundException",
    "message":"No custom object with key 'key_0815' for object type 'my_object_type' was found.
  }
}