Orders-orderId-account-products-productId-promotion:PUT
From Hostway API Documentation
Revision as of 09:07, 14 October 2014 by Mike.robski (Talk | contribs)
PUT /orders/{orderId}/account/products/{productId}/promotion
Set promotion code for a product in an order.
Contents |
Request
PUT /orders/{orderId}/account/products/{productId}/promotion
URI Parameters
- orderId - string
- The unique order Id. The URI of the order is returned by the POST /orders call.
- productId - string
- UUID specifying the product for which actions are to be performed
Query String Parameters
None.
Request Headers
- Content-Type
- Required. Set this header to
application/json; charset=UTF-8
- Cookie
- A cookie named OwnerId 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 the create order request in the Set-Cookie response header.
Request Body
{ "promoCode": "ThanksgivingPriceDrop" }
Request Body Parameters
- promoCode - string
- A promotion code to be applied to the product fees when retrieving the quote.
Response
Status Code
Status Code | Error Message | Description |
---|---|---|
204 No Content | - | The operation was successfully completed. |
400 Bad Request | POST data error | promoCode was not provided. |
401 Unauthorized | - | No owner Id specified or the specified owner is not authorized to add the promotion code. |
403 Forbidden | Unauthorized: PromotionView failed permission check | Set product promotion as an authenticated user, not associated with the order. |
404 Not Found | Resource not found | Order does not exist. |
Product does not exist. | ||
502 Bad Gateway | - | Unexpected backend response. Cannot apply promotion code. |
Example
Successfully add a promotion code for product
Request
PUT /orders/{orderId}/account/products/{product_id}/promotion Cookie: OwnerId={owner_id}; Path=/ { "promoCode": "ThanksgivingPriceDrop" }
Response
204 No Content
Missing promoCode field
Request
PUT /orders/{orderId}/account/products/{product_id}/promotion Cookie: OwnerId={owner_id}; Path=/ { "code": "ThanksgivingPriceDrop" }
Response
400 Bad Request Content-Type : application/json; charset=UTF-8 { "badRequest": { "guid": "ee20516d-011e-44ea-99d2-ae7a2b6fe99a", "message": "Resource not found", "code": 400, "details": { "promoCode": "Required" } } }
No authorization
Request
PUT /orders/{orderId}/account/user Cookie: OwnerId={wrong_owner_id}; Path=/ { "promoCode": "ThanksgivingPriceDrop" }
Response
401 Unauthorized Content-Type : text/plain; charset=UTF-8 401 Unauthorized This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.
Unassociated user without cookie
Request
PUT /orders/{orderId}/account/products/{productId}/promotion Authorization: {unassociated_user_authorization} { "promoCode": "truflex600_mitko" }
Response
403 Forbidden Content-Type: application/json; charset=UTF-8 { "forbidden" : { "guid" : "3e6e1847-402f-4a91-b083-190ca0713b23", "message" : "Unauthorized: PromotionView failed permission check", "code" : 403, "details" : "" } }
Order does not exist
Request
PUT /orders/{non-existent_orderId}/account/products/{product_id}/promotion Cookie: OwnerId={owner_id}; Path=/ { "promoCode": "ThanksgivingPriceDrop" }
Response
404 Not found Content-Type : application/json; charset=UTF-8 { "itemNotFound": { "guid": "ee20516d-011e-44ea-99d2-ae7a2b6fe99a", "message": "Resource not found", "code": 404, "details": "" } }
See also