CustomObjects Resource (Data API 16.4)

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/v16_4/custom_objects/{object_type}/{key}

Formats

json, xml

Response Document

CustomObject

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the custom object minLength=1, nullable=false
object_type String the ID of the object type 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
404 CustomObjectNotFoundException

key (String)

objectType (String)

For an unknown object key

Sample

REQUEST:
GET /s/-/dw/data/v16_4/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
ETag: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
{
  "_v" : "16.4",
   "_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":"16.4",
   "_type":"fault",
  "fault":
  {
    "type":"CustomObjectNotFoundException",
    "message":"No custom object with key 'key_0815' found for object type 'my_object_type'."
  }
}

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/v16_4/custom_objects/{object_type}/{key}

Formats

json, xml

Request Document

CustomObject

Response Document

CustomObject

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the custom object minLength=1, nullable=false
object_type String the ID of the object type 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.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, might be null
Returns:
  • Status.OK for success.
  • Status.ERROR for error.
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, might be null
Returns:
  • Status.OK for success.
  • Status.ERROR for error.

Sample

REQUEST:
PUT /s/-/dw/data/v16_4/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/v16_4/custom_objects/my_object_type/key_0815
ETag: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
{
  "_v" : "16.4",
  "_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":"16.4",
  "fault":
  {
    "type":"ObjectTypeNotFoundException",
    "message":"No object type with ID 'my_object_type' 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/v16_4/custom_objects/{object_type}/{key}

Formats

json, xml

Path Parameters

Parameter Type Description Constraints
key String the key attribute value of the custom object minLength=1, nullable=false
object_type String the ID of the object type 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
404 CustomObjectNotFoundException

key (String)

objectType (String)

For an unknown object key

Customization

This Resource supports server-side customization.

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

afterDelete () : Status

The function is called after the custom object was deleted.

Returns:
  • Status.OK for success.
  • Status.ERROR for error.
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:
  • Status.OK for success.
  • Status.ERROR for error.

Sample

REQUEST:
DELETE /s/-/dw/data/v16_4/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 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":"16.4",
  "fault":
  {
    "type":"ObjectTypeNotFoundException",
    "message":"No object type with ID 'my_object_type' 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/v16_4/custom_objects/{object_type}/{key}

Formats

json, xml

Request Document

CustomObject

Response Document

CustomObject

Path Parameters

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

Header Parameters

Parameter Type Description Constraints
If-Match String    

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.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:
  • Status.OK for success.
  • Status.ERROR for error.
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:
  • Status.OK for success.
  • Status.ERROR for error.

Sample

REQUEST:
PATCH /s/-/dw/data/v16_4/custom_objects/my_object_type/key_0815 HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
If-Match: abc45694thfs9c4398hf45fokjcsdioj5434lt34fx0ocerdfdfgf045ijg4590f
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 200 OK
Expires: Thu, 01-Jan-1970 00:00:00 GMT
ETag: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
{
   "_v" : "16.4",
   "_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":"16.4",
  "fault":
  {
    "type":"CustomObjectNotFoundException",
    "message":"No custom object with key 'key_0815' found for object type 'my_object_type'."
  }
}