Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This page contains an example of executing an end to end order against the API with HTTP level examples.

Creating a User

Request:

POST http://api.staging.milkbooks.com/user HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
Host: api.staging.milkbooks.com
Content-Length: 58
{"EmailAddress":"test1@example.com","Password":"test1234"}

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:21:46 GMT
Content-Length: 43
{"Id":2,"EmailAddress":"test1@example.com"}

Creating A Session

Request:

POST http://api.staging.milkbooks.com/session HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
Host: api.staging.milkbooks.com
Content-Length: 58
{"EmailAddress":"test1@example.com","Password":"test1234"}

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:22:04 GMT
Content-Length: 36
{"SessionId":"SWzj84qs39YaFMpkofna"}

Listing Products

Request:

GET http://api.staging.milkbooks.com/products HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
Host: api.staging.milkbooks.com

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:38:55 GMT
Content-Length: 56
{"Products":[{"Id":101397,"Name":"Japanese Photobook"}]}

Creating A Project

Request:

POST http://api.staging.milkbooks.com/project HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: SWzj84qs39YaFMpkofna
Host: api.staging.milkbooks.com
Content-Length: 42
{"Name":"Test Project","ProductId":101397}

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:41:35 GMT
Content-Length: 172
{"Guid":"e4a6f2011a1244ca9bfad7227903be4e","Name":"Test Project","ProductId":101397,"CreatedDateUtc":"\/Date(1366342895457)\/","LastSavedDateUtc":"\/Date(1366342895457)\/"}

Listing Projects

Request:

GET http://api.staging.milkbooks.com/projects HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: SWzj84qs39YaFMpkofna
Host: api.staging.milkbooks.com

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:42:33 GMT
Content-Length: 197
{"Projects":[{"Guid":"e4a6f2011a1244ca9bfad7227903be4e","Name":"Test Project","ProductId":101397,"CreatedDateUtc":"\/Date(1366368095457-0700)\/","LastSavedDateUtc":"\/Date(1366368095457-0700)\/"}]}

Creating A Basket

Request:

POST http://api.staging.milkbooks.com/basket HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: SWzj84qs39YaFMpkofna
Host: api.staging.milkbooks.com
content-length: 0

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:43:44 GMT
Content-Length: 131
{"Guid":"30296cecb5f54694923ede68545c6d72","Lines":[],"OrderTotal":0,"CreatedDateUtc":"\/Date(1366343024282)\/","LastSavedDateUtc":"\/Date(1366343024282)\/"}

Listing Baskets

Request:

GET http://api.staging.milkbooks.com/baskets HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: SWzj84qs39YaFMpkofna
Host: api.staging.milkbooks.com

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 19 Apr 2013 03:45:08 GMT
Content-Length: 277
{"Baskets":[{"Guid":"1ef8dc7d86a14454b3b0b880b36c82ff","Lines":[],"OrderTotal":0,"CreatedDateUtc":"\/Date(1366341815000)\/","LastSavedDateUtc":"\/Date(1366341815000)\/"},{"Guid":"30296cecb5f54694923ede68545c6d72","Lines":[],"OrderTotal":0,"CreatedDateUtc":"\/Date(1366343024000)\/","LastSavedDateUtc":"\/Date(1366343024000)\/"}]}

Adding a Project to a Basket (creating a Basket Line)

Request:

POST http://api.staging.milkbooks.com/basket/0accd97500e2431e97d5d951f18a6f28/line HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: +hJC5TsZW2JvaoEelccd
Host: api.staging.milkbooks.com
Content-Length: 63
{"ProjectGuid":"2babab85eaac428a9614d30e06daf737","Quantity":1}

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 17 May 2013 04:21:11 GMT
Content-Length: 95
{"Id":485630,"ProjectGuid":"2babab85eaac428a9614d30e06daf737","Quantity":1,"Total":39.98000000}

Getting a Basket (with Lines)

Request:

GET http://api.staging.milkbooks.com/basket/0accd97500e2431e97d5d951f18a6f28 HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: +hJC5TsZW2JvaoEelccd
Host: api.staging.milkbooks.com
Content-Length: 0

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 17 May 2013 04:21:19 GMT
Content-Length: 254
{"Guid":"0accd97500e2431e97d5d951f18a6f28","Lines":[{"Id":485630,"ProjectGuid":"2babab85eaac428a9614d30e06daf737","Quantity":1,"Total":39.9800}],"OrderTotal":39.9800,"CreatedDateUtc":"\/Date(1368764372000)\/","LastSavedDateUtc":"\/Date(1368764471000)\/"}

Updating a Basket Line Quantity

Request:

PUT http://api.staging.milkbooks.com/basket/0accd97500e2431e97d5d951f18a6f28/line/485630 HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: +hJC5TsZW2JvaoEelccd
Host: api.staging.milkbooks.com
Content-Length: 63
{"ProjectGuid":"2babab85eaac428a9614d30e06daf737","Quantity":7}

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 17 May 2013 04:21:52 GMT
Content-Length: 96
{"Id":485630,"ProjectGuid":"2babab85eaac428a9614d30e06daf737","Quantity":7,"Total":279.86000000}

Listing Baskets (with Lines)

Request:

GET http://api.staging.milkbooks.com/baskets HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: +hJC5TsZW2JvaoEelccd
Host: api.staging.milkbooks.com
Content-Length: 0

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 17 May 2013 04:22:02 GMT
Content-Length: 270
{"Baskets":[{"Guid":"0accd97500e2431e97d5d951f18a6f28","Lines":[{"Id":485630,"ProjectGuid":"2babab85eaac428a9614d30e06daf737","Quantity":7,"Total":279.8600}],"OrderTotal":279.8600,"CreatedDateUtc":"\/Date(1368764372000)\/","LastSavedDateUtc":"\/Date(1368764512000)\/"}]}

Deleting a Basket Line

Request:

DELETE http://api.staging.milkbooks.com/basket/0accd97500e2431e97d5d951f18a6f28/line/485630 HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: +hJC5TsZW2JvaoEelccd
Host: api.staging.milkbooks.com
Content-Length: 0

Response:

HTTP/1.1 204 Line deleted
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-Powered-By: ServiceStack/3.938 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 17 May 2013 04:22:28 GMT

 

  • No labels