Orders:POST

From Hostway API Documentation
Revision as of 12:12, 24 July 2015 by Mike.robski (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

POST /orders

Creates a new order and returns the unique order URI.

Contents


Request

POST /orders

URI Parameters

None.

Request Headers

Content-Type
Required. Set this header to application/json; charset=UTF-8
Cookie
Optional. A cookie named OwnerId may be specified to identify the client (for most browser clients, the browser will do this automatically, depending on the browser configuration). The value of the cookie would come from the response to a previous request for this resource (in the Set-Cookie response header).

Request Body

{
  "clientIp": {client_ip_address}
}
 

Parameters

clientIp - string
Optional. The IP address of the client that submitted the order. If not provided, the IP address of the client that called the API will be used. The IP address may be used to check the order for possible fraud. This parameter may be useful in cases where the API client accepts and relays orders from a 3rd-party customer (such as a shopping cart application). This parameter requires elevated permissions.

Response

Status Code

Status Code Error Message Description
201 Created - The new order was created.
400 Bad Request User cannot specify the client IP address The client attempted to pass the client IP address and is not allowed. Use of this parameter requires elevated permissions.
409 Conflict A new order has already been created for this ownerID The client already has an open order. If the OwnerId cookie was passed in the request headers, a 409 will be returned if there's already an open (unsubmitted) order for the same client.

Response Headers

Location
Returned with successful response. Contains the order URI. The client must use this URI for all subsequent operations with the order.
Set-Cookie
Returned with successful response. Contains an OwnerId value which must be submitted with all subsequent requests for this order. The OwnerId identifies the client and prohibits it from having more than one open (unsubmitted) orders.

Response Body

{
  "orderId": "{orderId}",
  "links": [
    {"href": "https://api.hostway.com/orders/", "rel": "self"},
    {"href": "https://api.hostway.com/orders/{orderId}", "rel": "item"}
  ]
}

Parameters

orderId - string
The Id of the new order
links - list
Hypermedia for this resource. Links to self and the newly created order.

Example

Create Order successfully

Request

POST /orders
Content-Type: application/json; charset=UTF-8

{}

Response

201 Created
Content-Type: application/json; charset=UTF-8
Location : https://api.hostway.com/orders/0000013ad6dd95746a399f90000a71384bf242cf
Set-Cookie : OwnerId=b0d6352a-f66a-476d-8e1d-2f3f9dea5c49; Path=/

{
  "orderId": "0000013ad6dd95746a399f90000a71384bf242cf",
  "links": [
    {"href": "https://api.hostway.com/orders/", "rel": "self"},
    {"href": "https://api.hostway.com/orders/0000013ad6dd95746a399f90000a71384bf242cf", "rel": "item"}
  ]
}


Create without permission to pass client IP

Request

POST /orders
Content-Type: application/json; charset=UTF-8
Authorization: Basic AuthString
{
  "clientIp": "1.2.3.4"
}

Response

400 Bad Request
Content-Type: application/json; charset=UTF-8

{
  "computeFault": {
  "guid": "143336cd-1763-4fe9-b3e3-c1e172b14fae",
  "message": "User cannot specify the client IP address",
  "code": 400, "details": ""
  }
}

An open order already exists

Request

POST /orders
Content-Type: application/json; charset=UTF-8
Cookie: OwnerId=0b3fc7bd-6905-4de7-bddb-43d2c7365e7a

{}

Response

409 Conflict
Content-Type: application/json; charset=UTF-8

{
  "conflict": {
    "guid": "e250bf7e-688d-45ba-8308-58374529be58",
    "message": "A new order has already been created for this ownerID",
    "code": 409,
    "details": ""
  }
}

See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox