4.4 Add a Book to a Catalog
In this example, the protocol client submits a request to add a book to the catalog.
The protocol client sends the following message:
-
POST /_vti_bin/client.svc/SampleCode.BookStore.Catalog/Books HTTP/1.1 Host: www.example.com Accept: */*, application/json Content-Type: application/json { '__metadata': {'type': 'SampleCode.Book'}, 'Title': 'Simple Cookbook', 'Author': 'Neil Black', 'Status': 2, 'PublishDate': '2009-08-01T00:00:00.0000000' }
The protocol server responds with the following message:
-
HTTP/1.1 201 Created Content-Type: application/json; charset=utf-8 { "d":{ "__metadata":{ "id":"fdda44df-a566-4df6-9b63-c3f8ac236377", "uri":"http://www.example.com/_vti_bin/client.svc/SampleCode.BookStore.Catalog/Books('63a687c6-921b-f898-4204-22f09533f28e')", "type":"SampleCode.Book" }, "Author":"Neil Black", "Id":"63a687c6-921b-f898-4204-22f09533f28e", "PublishDate":"\/Date(1249084800000)\/", "Status":2, "Title":"Simple Cookbook" } }