POST

A POST request is used to pass data to the server similar to pressing a “Submit” button on a web page to submit form data to the server. In the context of lgfapi, when making a POST request, the user is passing data to either create a resource or invoke a resource operation, such as cancelling an order. Unlike GET and HEAD requests, POST allows for text data to be passed in the free-form body of the request. Request body data must be in a supported format (JSON or XML) and follow the required structure of the API being invoked.

Content-Type HTTP Header

This HTTP header is required when using a method like POST, PATCH, and DELETE that allow transmitting data in the body of the request. It describes the data format so it can be correctly parsed server-side. Lgfapi supports JSON and XML input and therefore requires one of the two content-type values:

  • application/json
  • application/xml

The Content-Type “application/x-www-form-urlencoded” is not supported in lgfapi, but is still required for legacy OCWMS APIs.

Content Encoding

By default, lgfapi will use UTF-8 to decode the request body as this handles the majority of characters for languages supported in OCWMS. However, for situations where customers choose to use a different encoding, it can be specified in the Content-Type header’s optional “charset” parameter:

Content-Type: application/json; charset=latin-1

Lgfapi will use the provided charset to decode the request body data. It is up to the customer to ensure that their data is properly encoded using the desired charset before transmission to lgfapi. Failure to do so may result in incorrect characters or an inability to process the request.

It is also important to note that this only applies to the encoding of the request body and does not apply to the encoding used in any response body data from lgfapi.

Request Body Data – Repeated Keys

Lgfapi does not restrict users from repeating data in the request body for a single request. Rather, it will use only the final occurrence in the body when processing the request.

For example, if one were to send a request with the key “code” multiple times in the same request body:

{

code: A,

code: B

}

The value used to process the request will be “B”. “A” is ignored and is never used. There is no lgfapi use case for needing to pass repeating data in the same request.

Request Body List Formatting

JSON and XML data follow language standards except for the case of lists of items in XML. This is a unique concern for XML since there is no standard methodology for how to handle lists whereas JSON supports lists by default.

XML Lists

A list of items in XML is represented by the wrapper tag, followed by a wrapper for each item’s value with the special tag name “list-item”. For example, representing a list of serial numbers under the wrapper “serial_nbr_list”, in JSON is represent as:

{

serial_nbr_list: [ SN1,

SN2

]

}

The equivalent XML list would be represented as the following. Note the use of “list-item” for each entry in the list to allow for correct parsing.

<serial_nbr_list>

<list-item>SN1</list-item>

<list-item>SN2</list-item>

</serial_nbr_list>

Note: lgfapi is not intended to be directly called from a browser and users attempting it may run into CORS policy or other security errors. That is intended behavior. Use a non-browser application to make the API calls.