Orders-orderId-account-user:PUT

From Hostway API Documentation
Jump to: navigation, search

PUT /orders/{orderId}/account/user

Sets or updates the account user credentials in a given order.

Contents


Request

PUT /orders/{orderId}/account/user

Request Parameters

orderId - string
The unique order Id. The URI of the order is returned by the POST /orders call.

URI 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

{
  "userName": "mytestuser1",
  "password": "Mytestpass1"
}
 

Parameters

userName - string
Required string max 50 characters. Only letters, digits and dot (.), dash (-), underscore (_) and at sign (@) are allowed.
password - string
Required string min 8, max 50 characters. Must include at least one letter and one digit. The following characters are not allowed: &`'"\/<>$.

Response

Status Code

Status Code Error Message Description
200 OK - The operation was successfully completed.
400 Bad Request POST data error JSON is invalid
Username or password is missing.
Username or password breaks its format rules.
401 Unauthorized - No owner Id specified or the specified owner is not authorized to set user credentials.
403 Forbidden Unauthorized: User failed permission check Set user credentials as an authenticated user, not associated with the order.
404 Not Found Resource not found Order does not exist.
409 Confict Data conflict The same username already exists in the system.
502 Bad Gateway - Account hasn't been added

Response Body

None.


Example

Successfully add/update user to order

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

{
  "userName": "accountUser1",
  "password": "userPass1"
}

Response

204 No Content

Missing username

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

{
  "password": "userPass1"
}

Response

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

{
  "badRequest": {
    "guid": "50f051a3-8325-4064-b174-d82d78da83d9",
    "message": "POST data error",
    "code": 400,
    "details": {
      "userName": "Required"
    }
  }
}

Invalid username

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

{
  "userName": "user:name"
  "password": "userPass1"
}

Response

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

{
  "badRequest": {
    "guid": "50f051a3-8325-4064-b174-d82d78da83d9",
    "message": "POST data error",
    "code": 400,
    "details": {
      "userName": "Only letters, digits and dot (.), dash (-), underscore (_) and at sign (@) are allowed"
    }
  }
}

Invalid password

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

{
  "userName": "accountUser1"
  "password": "userPass$$$"
}

Response

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

{
  "badRequest": {
    "guid": "9cdfae0e-ad2a-4759-a5ef-ceddd2ac14be",
    "message": "POST data error",
    "code": 400,
    "details": {
      "password": "The following characters are not allowed: &`'\"\\/<>$"
    }
  }
}

No authorization

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={wrong_owner_id}; Path=/

{
  "userName": "accountUser1",
  "password": "userPass1"
}

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.

Unauthorized user

Request

PUT /orders/{orderId}/account/user
Authorization: {unassociated_user_authorization}

{
  "userName": "accountUser1",
  "password": "userPass1"
}

Response

403 Forbidden
Content-Type: application/json; charset=UTF-8

{
  "forbidden" : {
    "guid" : "66f63a81-52e9-4ec6-a50a-42acebc021e7",
    "message" : "Unauthorized: User failed permission check",
    "code" : 403,
    "details" : ""
  }
}

Order does not exist

Request

PUT /orders/{non-existent_orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

Response

404 Not found
Content-Type : application/json; charset=UTF-8

{
  "itemNotFound": {
    "guid": "cca219c5-3e2b-481d-8e7f-7083064872ff",
    "message": "Resource not found",
    "code": 404,
    "details": ""
  }
}

Existing account in the system

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

{
  "userName": "zxc01"
  "password": "Mytestpass1"
}

Response

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

{
  "conflict": {
    "guid": "5c817267-5302-4ea6-abd7-bc9b77f01082",
    "message": "Data conflict",
    "code": 409,
    "details": ""
  }
}

Account has not been set

Request

PUT /orders/{orderId}/account/user
Cookie: OwnerId={owner_id}; Path=/

{
  "userName": "accountUser1"
  "password": "userPass1"
}

Response

502 Bad Gateway
Content-Type : application/json; charset=UTF-8

{
  "computeFault": {
    "guid": "a4f6b310-11d9-4263-8482-81bccf261df7",
    "timestamp": "2014-09-08 08:34:20",
    "code": 502,
    "errorRefId":
    "a4f6b310-11d9-4263-8482-81bccf261df7"
  }
}

See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox