CodeVersions resource (Data API 23.2)
Summary
Http Method | Resource | Description |
---|---|---|
GET | /code_versions | Read all existing code versions. |
PUT | /code_versions/{code_version_id} | Create a new code version. |
PATCH | /code_versions/{code_version_id} | Update an existing code version.
|
GET | /code_versions/{code_version_id} | Read a code version. |
DELETE | /code_versions/{code_version_id} | Delete a code version. |
Get all code versions
Read all existing code versions.Url
GET https://hostname:port/dw/data/v23_2/code_versions
Formats
json, xml
Authentication
Name | Description |
---|---|
OAuth | Authentication via OAuth token. |
Response Document
Sample
REQUEST:
GET /s/-/dw/data/v23_2/code_versions HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
"_v" : "23.2",
"_type" : "code_version_result",
"count" : 1,
"data" :
[
{
"_type" : "code_version",
"_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
"activation_time" : "2016-01-14T16:48:07Z",
"active" : true,
"cartridges" : "bc_gillian, test_bc_wapi, test_bc_wapi_deprecated",
"compatibility_mode" : "16.2",
"id" : "version1",
"last_modification_time" : "2016-01-14T16:48:07Z",
"rollback" : false,
"total_size" : "537 KB",
"web_dav_url" : "https://example.com/on/demandware.servlet/webdav/Sites/Cartridges/version1"
}
],
"total" : 1
}
Create code version
Create a new code version.Url
PUT https://hostname:port/dw/data/v23_2/code_versions/{code_version_id}
Formats
json, xml
Authentication
Name | Description |
---|---|
OAuth | Authentication via OAuth token. |
Response Document
Path Parameters
Parameter | Type | Description | Constraints |
---|---|---|---|
code_version_id | String | The id of the code version. | minLength=1 |
In case of a failure Fault Document is returned.
Faults
Status | Type | Arguments | Description |
---|---|---|---|
409 | CodeVersionIdAlreadyExistsException |
codeVersionId (String) |
Indicates that a code version with the given id already exists. |
Sample
REQUEST:
PUT /s/-/dw/data/v23_2/code_versions/version2 HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8
Content-Length: 0
# 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/v23_2/code_versions/version2
{
"_v" : "23.2",
"_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
"_type" : "code_version",
"active" : false,
"compatibility_mode" : "16.2",
"creation_time" : "2016-01-15T10:52:50Z",
"id" : "version2",
"last_modification_time" : "2016-01-15T10:52:50Z",
"rollback" : false,
"web_dav_url" : "https://example.com/on/demandware.servlet/webdav/Sites/Cartridges/version2"
}
# in case of failure:
HTTP/1.1 409 CONFLICT
{
"_v" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionIdAlreadyExistsException",
"message" : "The code version ID 'version2' already exists."
}
}
Update a code version
Update an existing code version.- Only an inactive code version can be updated.
- Only the active flag and the id can be changed. The active flag can therefore only set to "true".
- To set the active flag to "false" will not work.
Url
PATCH https://hostname:port/dw/data/v23_2/code_versions/{code_version_id}
Formats
json, xml
Authentication
Name | Description |
---|---|
OAuth | Authentication via OAuth token. |
Request Document
Response Document
Path Parameters
Parameter | Type | Description | Constraints |
---|---|---|---|
code_version_id | String | The id of the code version. | minLength=1 |
In case of a failure Fault Document is returned.
Faults
Status | Type | Arguments | Description |
---|---|---|---|
400 | CodeVersionModificationException |
codeVersionId (String) |
Indicates that a code version with the given id can't be updated (because it is active). |
404 | CodeVersionIdNotFoundException |
codeVersionId (String) |
Indicates that a code version with the given id was not found. |
409 | CodeVersionIdAlreadyExistsException |
codeVersionId (String) |
Indicates that a code version with the given id already exists. |
Sample
## Example 1:
REQUEST:
PATCH /s/-/dw/data/v23_2/code_versions/version2 HTTP/1.1
Host: example.com
{
"_resource_state" : "t9ccde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73b8h6"
"active": true
}
# in case of success:
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
"_v" : "23.2",
"_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
"_type" : "code_version",
"activation_time" : "2016-01-15T11:19:31Z",
"active" : true,
"compatibility_mode" : "16.2",
"creation_time" : "2016-01-15T11:19:31Z",
"id" : "version2",
"last_modification_time" : "2016-01-15T11:19:31Z",
"rollback" : false,
"web_dav_url" : "https://example.com/on/demandware.servlet/webdav/Sites/Cartridges/version2"
}
# in case of failure:
RESPONSE:
HTTP/1.1 404 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" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionIdNotFoundException",
"message" : "The code version with ID 'version2' could not be found."
}
}
## Example 2:
REQUEST:
PATCH /s/-/dw/data/v23_2/code_versions/version2 HTTP/1.1
Host: example.com
{
"_resource_state" : "t9ccde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73b8h6"
"id": "version3"
}
# in case of success:
RESPONSE:
HTTP/1.1 301 MOVED PERMANENTLY
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
Location: https://example.com/s/-/dw/data/v23_2/code_versions/version3
{
"_v" : "23.2",
"_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
"_type" : "code_version",
"activation_time" : "2016-01-15T11:19:31Z",
"active" : false,
"compatibility_mode" : "16.2",
"creation_time" : "2016-01-15T11:19:31Z",
"id" : "version3",
"last_modification_time" : "2016-01-15T11:19:31Z",
"rollback" : false,
"web_dav_url" : "https://example.com/on/demandware.servlet/webdav/Sites/Cartridges/version2"
}
# in case of failure:
RESPONSE:
HTTP/1.1 404 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" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionIdNotFoundException",
"message" : "The code version with ID 'version2' could not be found."
}
}
HTTP/1.1 400 BAD REQUEST
{
"_v" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionModificationException",
"message" : "The code version 'version2' is active and cannot be changed."
}
}
HTTP/1.1 409 CONFLICT
{
"_v" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version3"
},
"type" : "CodeVersionIdAlreadyExistsException",
"message" : "The code version ID 'version3' already exists."
}
}
Get a code version
Read a code version.Url
GET https://hostname:port/dw/data/v23_2/code_versions/{code_version_id}?expand={String}
Formats
json, xml
Authentication
Name | Description |
---|---|
OAuth | Authentication via OAuth token. |
Response Document
Path Parameters
Parameter | Type | Description | Constraints |
---|---|---|---|
code_version_id | String | The id of the code version. | minLength=1 |
Query Parameters
Parameter | Type | Description | Constraints |
---|---|---|---|
expand | String | The expand parameter. Allowed value (size). |
In case of a failure Fault Document is returned.
Faults
Status | Type | Arguments | Description |
---|---|---|---|
404 | CodeVersionIdNotFoundException |
codeVersionId (String) |
Indicates that a code version with the given id was not found. |
Sample
REQUEST:
GET /s/-/dw/data/v23_2/code_versions/version2 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
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
"_v" : "23.2",
"_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
"_type" : "code_version",
"activation_time" : "2016-01-14T16:48:07Z",
"active" : true,
"cartridges" : [ "storefront", "storefront_richUI", "sitegenesis", "sitegenesis_richUI" ],
"compatibility_mode" : "16.2",
"id" : "version2",
"last_modification_time" : "2016-01-14T16:48:07Z",
"rollback" : false,
"total_size" : 537345,
"web_dav_url" : "https://example.com/on/demandware.servlet/webdav/Sites/Cartridges/version2"
}
# in case of failure:
RESPONSE:
HTTP/1.1 404 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" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionIdNotFoundException",
"message" : "The code version with ID 'version2' could not be found."
}
}
Delete a code version
Delete a code version.Url
DELETE https://hostname:port/dw/data/v23_2/code_versions/{code_version_id}
Formats
json, xml
Authentication
Name | Description |
---|---|
OAuth | Authentication via OAuth token. |
Path Parameters
Parameter | Type | Description | Constraints |
---|---|---|---|
code_version_id | String | The id of the code version. | minLength=1 |
In case of a failure Fault Document is returned.
Faults
Status | Type | Arguments | Description |
---|---|---|---|
400 | CodeVersionModificationException |
codeVersionId (String) |
Indicates that a code version with the given id can't be deleted (because it is active). |
404 | CodeVersionIdNotFoundException |
codeVersionId (String) |
Indicates that a code version with the given id was not found. |
Sample
REQUEST:
DELETE /s/-/data/v23_2/code_versions/version2 HTTP/1.1
Host: example.com
Content-Type: application/json; charset=UTF-8
x-dw-resource-state: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
# in case of success:
RESPONSE:
HTTP/1.1 204 NO CONTENT
# in case of failure:
RESPONSE:
HTTP/1.1 404 NOT FOUND
Content-Type: application/json; charset=UTF-8
{
"_v" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionIdNotFoundException",
"message" : "The code version with ID 'version2' could not be found."
}
}
HTTP/1.1 400 BAD REQUEST
{
"_v" : "23.2",
"fault" :
{
"arguments" :
{
"codeVersionId" : "version2"
},
"type" : "CodeVersionModificationException",
"message" : "The code version 'version2' is active and cannot be changed."
}
}
X
OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.