Orders:POST
From Hostway API Documentation
(Difference between revisions)
Mike.robski (Talk | contribs) |
Mike.robski (Talk | contribs) m (1 revision: Release 109) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 18: | Line 18: | ||
=== Request Body === | === Request Body === | ||
<nowiki> | <nowiki> | ||
− | {} | + | { |
+ | "clientIp": {client_ip_address} | ||
+ | } | ||
</nowiki> | </nowiki> | ||
+ | |||
+ | ==== 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 == | == Response == | ||
=== Status Code === | === Status Code === | ||
− | + | {| class="wikitable" | |
− | + | ! Status Code | |
− | + | ! Error Message | |
− | + | ! Description | |
− | + | |- | |
+ | | 201 Created | ||
+ | | align="center" | - | ||
+ | | 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 === | === Response Headers === | ||
Line 45: | Line 63: | ||
{"href": "</nowiki>{{APIBaseURL}}<nowiki>/orders/{orderId}", "rel": "item"} | {"href": "</nowiki>{{APIBaseURL}}<nowiki>/orders/{orderId}", "rel": "item"} | ||
] | ] | ||
− | } | + | }</nowiki> |
− | + | ||
==== Parameters ==== | ==== Parameters ==== | ||
Line 57: | Line 74: | ||
== Example == | == Example == | ||
− | === | + | === Create Order successfully === |
+ | '''Request''' | ||
<nowiki> | <nowiki> | ||
POST /orders | POST /orders | ||
Content-Type: application/json; charset=UTF-8 | Content-Type: application/json; charset=UTF-8 | ||
− | {} | + | {}</nowiki> |
− | + | ||
− | + | '''Response''' | |
<nowiki> | <nowiki> | ||
201 Created | 201 Created | ||
Line 73: | Line 90: | ||
{ | { | ||
− | + | "orderId": "0000013ad6dd95746a399f90000a71384bf242cf", | |
− | + | "links": [ | |
− | + | {"href": "</nowiki>{{APIBaseURL}}<nowiki>/orders/", "rel": "self"}, | |
− | + | {"href": "</nowiki>{{APIBaseURL}}<nowiki>/orders/0000013ad6dd95746a399f90000a71384bf242cf", "rel": "item"} | |
− | + | ] | |
− | } | + | }</nowiki> |
− | </nowiki> | + | |
+ | |||
+ | === Create without permission to pass client IP === | ||
+ | '''Request''' | ||
+ | <nowiki> | ||
+ | POST /orders | ||
+ | Content-Type: application/json; charset=UTF-8 | ||
+ | Authorization: Basic AuthString | ||
+ | { | ||
+ | "clientIp": "1.2.3.4" | ||
+ | }</nowiki> | ||
+ | |||
+ | '''Response''' | ||
+ | <nowiki> | ||
+ | 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": "" | ||
+ | } | ||
+ | }</nowiki> | ||
+ | |||
+ | === An open order already exists === | ||
+ | '''Request''' | ||
+ | <nowiki> | ||
+ | POST /orders | ||
+ | Content-Type: application/json; charset=UTF-8 | ||
+ | Cookie: OwnerId=0b3fc7bd-6905-4de7-bddb-43d2c7365e7a | ||
+ | |||
+ | {}</nowiki> | ||
+ | |||
+ | '''Response''' | ||
+ | <nowiki> | ||
+ | 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": "" | ||
+ | } | ||
+ | }</nowiki> | ||
== See also == | == See also == |
Latest revision as of 12:12, 24 July 2015
[edit] POST /orders
Creates a new order and returns the unique order URI.
Contents |
[edit] Request
POST /orders
[edit] URI Parameters
None.
[edit] 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).
[edit] Request Body
{ "clientIp": {client_ip_address} }
[edit] 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.
[edit] Response
[edit] 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. |
[edit] 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.
[edit] Response Body
{ "orderId": "{orderId}", "links": [ {"href": "https://api.hostway.com/orders/", "rel": "self"}, {"href": "https://api.hostway.com/orders/{orderId}", "rel": "item"} ] }
[edit] Parameters
- orderId - string
- The Id of the new order
- links - list
- Hypermedia for this resource. Links to self and the newly created order.
[edit] Example
[edit] 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"} ] }
[edit] 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": "" } }
[edit] 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": "" } }
[edit] See also