Orders-orderId-account-user:PUT

From Hostway API Documentation
(Difference between revisions)
Jump to: navigation, search
 
m (1 revision: Release 99)
 
(6 intermediate revisions by 3 users not shown)
Line 28: Line 28:
 
==== Parameters ====
 
==== Parameters ====
 
; userName - ''string''
 
; userName - ''string''
: Required string max 50 characters. Only letters, digits and dot (.), dash (-) and underscore (_) are allowed.
+
: Required string max 50 characters. Only letters, digits and dot (.), dash (-), underscore (_) and at sign (@) are allowed.
  
 
; password - ''string''
 
; password - ''string''
Line 34: Line 34:
  
 
== Response ==
 
== Response ==
 
 
=== Status Code ===
 
=== Status Code ===
;204 No Content
+
{| class='wikitable'
: The operation was successfully completed.
+
|-
 
+
! Status Code
;400 Bad Request
+
! Error Message
: The request body contains invalid JSON or the values do not adhere to the restrictions set for them.
+
! Description
 
+
|-
;404 Not Found
+
| 200 OK
: An account has not been added to the given order or the order does not exist.
+
| align="center" | -
 +
| The operation was successfully completed.
 +
|-
 +
| rowspan="3" | 400 Bad Request
 +
| rowspan="3" | POST data error
 +
| JSON is invalid
 +
|-
 +
| Username or password is missing.
 +
|-
 +
| Username or password breaks its format rules.
 +
|-
 +
| 401 Unauthorized
 +
| align="center" | -
 +
| 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
 +
| align="center" | -
 +
| Account hasn't been added
 +
|}
  
 
=== Response Body ===
 
=== Response Body ===
 
None.
 
None.
 +
 +
 +
== Example ==
 +
=== Successfully add/update user to order ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/
 +
 +
{
 +
  "userName": "accountUser1",
 +
  "password": "userPass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
204 No Content</nowiki>
 +
 +
=== Missing username ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/
 +
 +
{
 +
  "password": "userPass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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"
 +
    }
 +
  }
 +
}</nowiki>
 +
 +
=== Invalid username ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/
 +
 +
{
 +
  "userName": "user:name"
 +
  "password": "userPass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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"
 +
    }
 +
  }
 +
}</nowiki>
 +
 +
=== Invalid password ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/
 +
 +
{
 +
  "userName": "accountUser1"
 +
  "password": "userPass$$$"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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: &`'\"\\/<>$"
 +
    }
 +
  }
 +
}</nowiki>
 +
 +
=== No authorization ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={wrong_owner_id}; Path=/
 +
 +
{
 +
  "userName": "accountUser1",
 +
  "password": "userPass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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.</nowiki>
 +
 +
=== Unauthorized user ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Authorization: {unassociated_user_authorization}
 +
 +
{
 +
  "userName": "accountUser1",
 +
  "password": "userPass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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" : ""
 +
  }
 +
}</nowiki>
 +
 +
=== Order does not exist ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{non-existent_orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
404 Not found
 +
Content-Type : application/json; charset=UTF-8
 +
 +
{
 +
  "itemNotFound": {
 +
    "guid": "cca219c5-3e2b-481d-8e7f-7083064872ff",
 +
    "message": "Resource not found",
 +
    "code": 404,
 +
    "details": ""
 +
  }
 +
}</nowiki>
 +
 +
=== Existing account in the system ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/
 +
 +
{
 +
  "userName": "zxc01"
 +
  "password": "Mytestpass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
409 Conflict
 +
Content-Type : application/json; charset=UTF-8
 +
 +
{
 +
  "conflict": {
 +
    "guid": "5c817267-5302-4ea6-abd7-bc9b77f01082",
 +
    "message": "Data conflict",
 +
    "code": 409,
 +
    "details": ""
 +
  }
 +
}</nowiki>
 +
 +
=== Account has not been set ===
 +
'''Request'''
 +
<nowiki>
 +
PUT /orders/{orderId}/account/user
 +
Cookie: OwnerId={owner_id}; Path=/
 +
 +
{
 +
  "userName": "accountUser1"
 +
  "password": "userPass1"
 +
}</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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"
 +
  }
 +
}</nowiki>
  
 
== See also ==
 
== See also ==

Latest revision as of 09:06, 14 October 2014

[edit] PUT /orders/{orderId}/account/user

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

Contents


[edit] Request

PUT /orders/{orderId}/account/user

[edit] Request Parameters

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

[edit] URI Parameters

None.

[edit] 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.

[edit] Request Body

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

[edit] 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: &`'"\/<>$.

[edit] Response

[edit] 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

[edit] Response Body

None.


[edit] Example

[edit] 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

[edit] 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"
    }
  }
}

[edit] 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"
    }
  }
}

[edit] 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: &`'\"\\/<>$"
    }
  }
}

[edit] 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.

[edit] 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" : ""
  }
}

[edit] 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": ""
  }
}

[edit] 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": ""
  }
}

[edit] 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"
  }
}

[edit] See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox