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":"test2@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: Wed, 26 Jun 2013 00:29:17 GMT
Content-Length: 44
{"Id":30,"EmailAddress":"test2@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":"test2@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: Wed, 26 Jun 2013 00:29:40 GMT
Content-Length: 36
{"SessionId":"aH41qm9/cnNEMCz3CAgs"}
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
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: Wed, 26 Jun 2013 00:30:20 GMT
Content-Length: 121
{"Products":[{"Id":106697,"Name":"Japanese Photobook","Price":39.9500},{"Id":108089,"Name":"Test Book","Price":39.9500}]}
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: aH41qm9/cnNEMCz3CAgs
Host: api.staging.milkbooks.com
Content-Length: 42
{"Name":"Test Project","ProductId":106697}
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: Wed, 26 Jun 2013 00:31:26 GMT
Content-Length: 479
{"Guid":"e92f870a47fa4326b97bb21e074fd540","Name":"Test Project","ProductId":106697,"Versions":[{"Number":1,"IsComplete":false,"Artifacts":[{"Name":"small_cover_sticker","IsComplete":false,"FileMimeType":"application/pdf"},{"Name":"pages","IsComplete":false,"FileMimeType":"application/pdf"}],"CreatedDateTimeUtc":"\/Date(1372206685926)\/","LastSavedDateTimeUtc":"\/Date(1372206685926)\/"}],"CreatedDateUtc":"\/Date(1372206685926)\/","LastSavedDateUtc":"\/Date(1372206685926)\/"}
Completing A Required Artifact
Request:
POST http://api.staging.milkbooks.com/project/e92f870a47fa4326b97bb21e074fd540/version/1/artifact/small_cover_sticker HTTP/1.1
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
Host: api.staging.milkbooks.com
Content-Length: 238
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="book_small_cover_sticker_32100.pdf"
Content-Type: application/pdf
PDF 1.4 etc...
---------------------------acebdf13572468--
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: Wed, 26 Jun 2013 00:33:49 GMT
Content-Length: 351
{"Number":1,"IsComplete":false,"Artifacts":[{"Name":"small_cover_sticker","IsComplete":true,"FileMimeType":"application/pdf","FileSize":14,"FileMd5":"05A188351B5848E2FD5B062D80D1A754"},{"Name":"pages","IsComplete":false,"FileMimeType":"application/pdf"}],"CreatedDateTimeUtc":"\/Date(1372231885927)\/","LastSavedDateTimeUtc":"\/Date(1372231885927)\/"}
Completing A Required Artifact which completes a Version
Request:
POST http://api.staging.milkbooks.com/project/e92f870a47fa4326b97bb21e074fd540/version/1/artifact/pages HTTP/1.1
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
Host: api.staging.milkbooks.com
Content-Length: 224
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="book_pages_32100.pdf"
Content-Type: application/pdf
PDF 1.4 etc...
---------------------------acebdf13572468--
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: Wed, 26 Jun 2013 00:34:18 GMT
Content-Length: 408
{"Number":1,"IsComplete":true,"Artifacts":[{"Name":"small_cover_sticker","IsComplete":true,"FileMimeType":"application/pdf","FileSize":14,"FileMd5":"05A188351B5848E2FD5B062D80D1A754"},{"Name":"pages","IsComplete":true,"FileMimeType":"application/pdf","FileSize":14,"FileMd5":"05A188351B5848E2FD5B062D80D1A754"}],"CreatedDateTimeUtc":"\/Date(1372231885927)\/","LastSavedDateTimeUtc":"\/Date(1372231885927)\/"}
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:
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: Wed, 26 Jun 2013 00:35:01 GMT
Content-Length: 609
{"Projects":[{"Guid":"e92f870a47fa4326b97bb21e074fd540","Name":"Test Project","ProductId":106697,"Versions":[{"Number":1,"IsComplete":true,"Artifacts":[{"Name":"small_cover_sticker","IsComplete":true,"FileMimeType":"application/pdf","FileSize":14,"FileMd5":"05A188351B5848E2FD5B062D80D1A754"},{"Name":"pages","IsComplete":true,"FileMimeType":"application/pdf","FileSize":14,"FileMd5":"05A188351B5848E2FD5B062D80D1A754"}],"CreatedDateTimeUtc":"\/Date(1372231885927)\/","LastSavedDateTimeUtc":"\/Date(1372231885927)\/"}],"CreatedDateUtc":"\/Date(1372231885927)\/","LastSavedDateUtc":"\/Date(1372231885927)\/"}]}
Creating A Version
Request:
POST http://api.staging.milkbooks.com/project/e92f870a47fa4326b97bb21e074fd540/version HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 01:17:23 GMT
Content-Length: 293
{"Number":2,"IsComplete":false,"Artifacts":[{"Name":"small_cover_sticker","IsComplete":false,"FileMimeType":"application/pdf"},{"Name":"pages","IsComplete":false,"FileMimeType":"application/pdf"}],"CreatedDateTimeUtc":"\/Date(1372209443625)\/","LastSavedDateTimeUtc":"\/Date(1372209443625)\/"}
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: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 00:35:20 GMT
Content-Length: 157
{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[],"OrderTotal":0,"CreatedDateUtc":"\/Date(1372206920892)\/","LastSavedDateUtc":"\/Date(1372206920892)\/"}
Adding a Project to a Basket (creating a Basket Line)
Request:
POST http://api.staging.milkbooks.com/basket/80d968618ae54b4bae699a3b39aaadf5/line HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
Host: api.staging.milkbooks.com
Content-Length: 63
{"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","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: Wed, 26 Jun 2013 00:36:28 GMT
Content-Length: 376
{"Line":{"Id":588670,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":1,"Total":39.95000000},"Basket":{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[{"Id":588670,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":1,"Total":39.95000000}],"OrderTotal":39.95000000,"CreatedDateUtc":"\/Date(1372206920000)\/","LastSavedDateUtc":"\/Date(1372206988626)\/"}}
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: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 00:36:52 GMT
Content-Length: 268
{"Baskets":[{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[{"Id":588670,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":1,"Total":39.9500}],"OrderTotal":39.9500,"CreatedDateUtc":"\/Date(1372206920000)\/","LastSavedDateUtc":"\/Date(1372206988000)\/"}]}
Getting a Basket (with Lines)
Request:
GET http://api.staging.milkbooks.com/basket/80d968618ae54b4bae699a3b39aaadf5 HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 00:38:25 GMT
Content-Length: 256
{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[{"Id":588670,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":7,"Total":279.6500}],"OrderTotal":279.6500,"CreatedDateUtc":"\/Date(1372206920000)\/","LastSavedDateUtc":"\/Date(1372207083000)\/"}
Updating a Basket Line Quantity
Request:
PUT http://api.staging.milkbooks.com/basket/80d968618ae54b4bae699a3b39aaadf5/line/588670 HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
Host: api.staging.milkbooks.com
Content-Length: 63
{"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","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: Wed, 26 Jun 2013 00:38:03 GMT
Content-Length: 379
{"Line":{"Id":588670,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":7,"Total":279.65000000},"Basket":{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[{"Id":588670,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":7,"Total":279.65000000}],"OrderTotal":279.65000000,"CreatedDateUtc":"\/Date(1372206920000)\/","LastSavedDateUtc":"\/Date(1372207083630)\/"}}
Deleting a Basket Line
Request:
DELETE http://api.staging.milkbooks.com/basket/80d968618ae54b4bae699a3b39aaadf5/line/588670 HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 00:39:06 GMT
Content-Length: 168
{"Basket":{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[],"OrderTotal":0,"CreatedDateUtc":"\/Date(1372206920000)\/","LastSavedDateUtc":"\/Date(1372207146747)\/"}}
Add a Basket Line back in
Request:
POST http://api.staging.milkbooks.com/basket/80d968618ae54b4bae699a3b39aaadf5/line HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
Host: api.staging.milkbooks.com
Content-Length: 63
{"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","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: Wed, 26 Jun 2013 00:40:09 GMT
Content-Length: 376
{"Line":{"Id":588671,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":1,"Total":39.95000000},"Basket":{"Guid":"80d968618ae54b4bae699a3b39aaadf5","Lines":[{"Id":588671,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":1,"Total":39.95000000}],"OrderTotal":39.95000000,"CreatedDateUtc":"\/Date(1372206920000)\/","LastSavedDateUtc":"\/Date(1372207209755)\/"}}
Retrieve A Checkout URL
Request:
POST http://api.staging.milkbooks.com/basket/80d968618ae54b4bae699a3b39aaadf5/checkout HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 00:40:27 GMT
Content-Length: 153
{"BasketGuid":"80d968618ae54b4bae699a3b39aaadf5","CheckoutUrl":"http://checkout.api.staging.milkbooks.com/start.aspx?token=3456bbc7-0494-435f-b7da-e37d0e696500"}
Retrieve Orders
Unknown macro: {Not deployed to Staging Yet}
Request:
GET http://api.staging.milkbooks.com/orders HTTP/1.1
content-type: application/json
accept: application/json
x-milk-api-key: 12345678-1234-1234-1234-123456789012
x-milk-session-id: aH41qm9/cnNEMCz3CAgs
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: Wed, 26 Jun 2013 00:40:27 GMT
Content-Length: 153
{"Orders":[{"OrderGuid":"00000000000000000000000000000000","Lines":[{"Id":0,"ProjectGuid":"e92f870a47fa4326b97bb21e074fd540","Quantity":1,"Total":39.95000000}],
"OrderTotal":39.5,"Status":"Processing","CreatedDateUtc":"\/Date(-62135596800000+1300)\/","CompletedDateUtc":"\/Date(-62135596800000+1300)\/","LastSavedDateUtc":"\/Date(-62135596800000+1300)\/"}]}