IOM REST API - Create Stock Reservation

URI

servlets/services/reservation/<shopId>

Http Method

POST

Short Description

Create a stock reservation.
Example Requests URLhttp://10.17.0.245:8080/servlets/services/reservation/10010

Example Requests

{ "lifetime": 180, "type": "COMPLETE", "items": [ { "id": "First-Test", "qty": "2" } ] }

HTTP Status Codes

  • 201 Created

  • 400 Bad Request

  • 401 Unauthorized

  • 404 Not Found

  • 500 Internal Server Error

Description

This service creates stock reservations for a given OMS shop instance. A stock reservation is a list of reserved products with the appropriate amount. Each stock reservation has a validity which can be set by the field lifetime at the request payload.

The response provides a status code 201 on success with the reserved products, the state of the reservation and a unique reservation reference ID.

This service only supports and accepts requests with content-type application/json.

ParametersPath parameter shopId = ID of the OMS shop instance - Example = 10010

Product Version

1.1

Product To Version

 
Status

final

Authorization

IOM supports "basic http authentication" only. Please configure your clients to use this authentication method. A very simple method to send REST requests on the command line can be realized using wget. The example also shows, how to configure this client to use "basic http authentication" (--auth-no-challenge).

 

wget -q -O- --auth-no-challenge  --http-user=<user> --http-password='<password>' \
--method=post --post-data='{"lifetime":180, "type":"COMPLETE", "items":[{"id":"First-Test", "qty":"2"}]}' \
http://<hostname>/servlets/services/reservation/10010

 

It is Important that the permission REST_RESERVATION (oms.RightDefDO with ID = 124 and name "Reservation REST service") is assigned to the requesting user. The permission is a part of the class bakery.persistence.dataobject.configuration.common.RightDefDO.

The user also needs the permission for the OMS shop instance which relates to the requested stock reservation.

Concurrency

To avoid overbooking of products the OMS checks the current inventory of the product before storing the reservation. The inventory check itself depends on stock reservations. For this reason the OMS uses database advisory locks to serialize the requests.

If it is not possible for a request to obtain all locks for the products to reverse within five seconds, the client gets a response with HTTP status code 500 and the following payload:

{
  "data": null,
  "statusCode": 500,
  "errors": null,
  "exceptions": [{
      "code": "500",
      "message": "bakery.util.exception.TechnicalException: Technical error while working on object 'ReservationPersistenceBean': 
			Unable to create reservation. Cannot get the necessary database lock to perform a concurrent safe inventory check."
    }]
}

JSON

Request data format

application/json

Request related java object

bakery.v2.reservation.ReservationRequestImpl
Request Attributes
Attribute
Description
TypeNullable
lifetime

The lifetime / validity of the stock reservation in seconds.Max value is 2147483647.
Greater values creates a response with HTTP status code 400 caused by a JsonParseException,

Default is 10 minutes.

Integertrue
type

The reservation type:

  • COMPLETE = products are only reserved if all products of the request are reservable

  • PARTLY = products are reserved, even when one or more of the reserved products are not reservable

If type is missing the OMS uses COMPLETE. All values unequal COMPLETE be interpreted as PARTLY.

Stringtrue
items1..n products to reserve. For details see table below.Arrayfalse
Item Attribute
Description
TypeSizeNullable
idThe ID of the product. Via the OMS configurations it is determined if it is the shop or oms product ID.String30false
qtyQuantity to reserveInteger false

Request data example

{
  "lifetime": 180,
  "type": "COMPLETE",
  "items": [
    {
      "id": "First-Test",
      "qty": "2"
    }
  ]
}

Response data format

application/json

Response related java object

bakery.webservice.rest.v1.HttpResponse
bakery.reservation.v2.ReservationResponse as "data" object
Response Attributes
AttributesDescription
datasee table below
statusCodeHTTP status code
errorsempty in case of successful processing. For details see Response Attribute Errors
exceptionsempty in case of successful processing. For details see Response Attribute Exceptions
Data Attributes
Description
validUntilThe Validity of the Stock Reservation
resvIdThe id <primary key> of the Stock Reservation
items1..n items. See table below
Item Attributes
Description
idThe ID of the product. Via the OMS configurations it is determined if it is the shop product number or the oms product ID.
qtyReserved quantity
state

State of the reservation.
The reservation of the product is still "revered" or "expired".

Response AttributeErrors
Source FieldMessage
items.qtyCannot construct instance of int from String value 'value from request': not a valid Integer value

HTTP status code= 400

Response AttributeExceptions
CodeDescription
JsonParseExceptionFor each not well formed JSON request payload
CODE_21001The product to be reserved was not found
CODE_21003We don't have enough stock for requested product

HTTP status code= 400

Response data example
{
  "data": {
    "validUntil": "2016-01-07 15:03:36",
    "resvId": 119,
    "items": [
      {
        "id": "First-Test",
        "qty": 2,
        "state": "reserved"
      }
    ]
  },
  "statusCode": 201,
  "errors": [
  ],
  "exceptions": [
  ]
}
Response Code201

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Support Tickets