The WCO-API is a new way to access and edit the state of WebCheckout via HTTP in a RESTful style using JSON.
Latter pages in this document will assume you are familiar with the former sections. Please do read through at least the first 4 sections in their entirety.
It is assumed that the reader has some knowledge of JSON and RESTful APIs in general. This document may include examples, but it is not intended to be a complete how-to guide or an introduction to RESTful APIs.
There is not always complete agreement on what is and is not RESTy. We have no intention of wading into that debate. Our API is being used to progressively modernize our application and as such, during its development, is subject to the needs of a living breathing application and user base. In short, those places where we have strayed from the REST paradigm are likely to have been caused by the need to follow design patterns and use cases that have developed over many years.
Let's get some conventions out of the way. Throughout this document, when ever we need to format a post to the API along with the posted data is formatted as so...
POST URL
{ "hello": "world" }
Similarly, the status code and the JSON returned by the API is formatted thus...
HTTP 200
{ "json": "awesome" }
The language of our core, ANSI Common Lisp, is historically a case insensitive language. Common lisp identifiers are written with hyphens separating words (for example "my-identifier"). On the other hand JavaScript, the anticipated client of the API, is case sensitive, reserving the '-' character for subtraction, and so uses lowerCamelCase ("myIdentifier") for non-quoted symbols. JSON keys are quoted strings, so they can go either way. Don't get me started on HTML element tags and Angular directives.
We opted to pretend in the API that the lisp 'hyphenated case' doesn't exist since it tends to perplex those more familiar with JavaScript. That said, While reading these documents you may find either of the cases or, if we are really trying to trip you up, we may actually use multiple words. So allocationItem, allocation-item, and allocation item may all refer to the same thing. We will try to keep this to a minimum.
As we normalize these docs we are going to err on the side of lowerCamelCase. Sorry in advance for any confusion
Namespaces are the highest level separation of REST operations. All operations in the API exist under a namespace, most namespaces correspond to a specific Framework Entity (such as a person or an allocation) However, some special namespaces exist that have their own conventions.
Entities are complex objects in the WebCheckout core and are handled in their own section.
rest/<namespace>/<optional command or object identifier>
All Messages to and from the REST API should be encoded with the Content-Type "application/json; charset=UTF-8".
All arguments and data are passed to and from the REST API in the HTTP Request and Response payload as UTF-8 Formatted JSON.
All operations to the WebCheckout REST API use the HTTP POST operation.
The API Version is intended to communicate major changes in the API to third party users. Currently the API is version 2.0.
The request processed correctly
There was an error in the REST server or the Framework
The session is not authenticated
The session organization must be set to perform this operation
The session checkout center must be set to perform this operation
The consumer must provide additional authentication to complete the previous operation.
The consumers attempt to provide additional authorization information failed.
[ { "message": "Everything is coming up Millhouse", "type": "success" } ]
All successful REST API calls will return the HTTP response code 200. Only extra-protocol errors use HTTP response codes.
There are some circumstances when the code is non-200
POST /rest/person/noSuchCommand HTTP/1.1
{ "headers": { "Authorization": "Bearer eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=" } }
HTTP 400
{ "apiVersion": "2.0", "uri": "/rest/person/noSuchCommand", "session": { "id": "S-78064", "agent": { "_class": "person", "oid": 533, "name": "Super", "avatar": null, "lastName": null, "otherName": "", "firstName": "Super", "userid": "adminuser" }, "checkoutCenter": null, "organization": null, "focusAllocation": null, "editingAllocations": null, "transientDocuments": null, "resetTimeout": false, "resetApproved": false }, "status": "error", "notifications": null, "alert": null, "payload": { "message": "Requested command NO-SUCH-COMMAND was not found in namespace PERSON", "class": "REST-SERVER:FRAMEWORK-COMMAND-NOT-FOUND" }, "sessionToken": "eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=", "sessionid": "b2f8590c-5d09-440d-aa68-53dd64fc661c" }
POST /rest/noSuchNameSpace/noSuchCommand HTTP/1.1
{ "headers": { "Authorization": "Bearer eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=" } }
HTTP 404
{ "apiVersion": "2.0", "uri": "/rest/noSuchNameSpace/noSuchCommand", "session": { "id": "S-78064", "agent": { "_class": "person", "oid": 533, "name": "Super", "avatar": null, "lastName": null, "otherName": "", "firstName": "Super", "userid": "adminuser" }, "checkoutCenter": null, "organization": null, "focusAllocation": null, "editingAllocations": null, "transientDocuments": null, "resetTimeout": false, "resetApproved": false }, "status": "error", "notifications": null, "alert": null, "payload": { "message": "Requested namespace NO-SUCH-NAME-SPACE was not found", "class": "REST-SERVER:NAMESPACE-NOT-FOUND" }, "sessionToken": "eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=", "sessionid": "b2f8590c-5d09-440d-aa68-53dd64fc661c" }
GET /rest/session/currentSession HTTP/1.1
{ "headers": { "Authorization": "Bearer eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=" } }
HTTP 405
{ "apiVersion": "2.0", "uri": "/rest/session/currentSession", "session": null, "status": "error", "notifications": null, "alert": null, "payload": { "message": "All WCO API commands require the HTTP POST method", "class": "REST-SERVER:METHOD-NOT-ALLOWED" } }
POST /rest/session/testError HTTP/1.1
{ "headers": { "Authorization": "Bearer eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=" } }
HTTP 500
{ "apiVersion": "2.0", "uri": "/rest/session/testError", "session": { "id": "S-78064", "agent": { "_class": "person", "oid": 533, "name": "Super", "avatar": null, "lastName": null, "otherName": "", "firstName": "Super", "userid": "adminuser" }, "checkoutCenter": null, "organization": null, "focusAllocation": null, "editingAllocations": null, "transientDocuments": null, "resetTimeout": false, "resetApproved": false }, "status": "error", "notifications": null, "alert": null, "payload": { "message": "TEST ERROR", "class": "COMMON-LISP:SIMPLE-ERROR" }, "sessionToken": "eyJ0eXBlIjogInNlc3Npb24iLCAidmFsdWUiOiAiYjJmODU5MGMtNWQwOS00NDBkLWFhNjgtNTNkZDY0ZmM2NjFjIn0=", "sessionid": "b2f8590c-5d09-440d-aa68-53dd64fc661c" }