Errata

REST in Practice

Errata for REST in Practice

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed, PDF,
Page 10
Figure 1-4

Order shows Coffee: Late. Presumably this should be "Latte", although "Payment: $3.50" represents a considerable discount to the market, and this may be a discount offered for tardiness.

Note from the Author or Editor:
Change the coffee part of the order (leftmost box in figure 1-4) to read:

Coffee: Latte

Note: this bug was introduced by O'Reilly's graphics people. It was not there in the source material.

Anonymous  Dec 29, 2010  May 22, 2015
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 10
Figure 1-4

It shows mismatched tags in the XML.

It has:

<coffee>Latte</order>

surely it should be:

<coffee>Latte</coffee>

As the <order> and </order> tags are already present.


Note from the Author or Editor:
Figure 1.4 is yet another case of the O'Reilly in house art team providing inferior diagrams and introducing mistakes compared to the original provided by the authors.

Please replace the line in the XML in the green box from:

<coffee>latte</order>

To:

<coffee>latte</coffee>

Lee Gibson  Nov 29, 2016 
14
Figure 1-7

The green box representing state 3 shows links to states 1 and 5. However the link to state 5 (pink) actually points back to the pink box that represents state 6. I suggest correcting the numeral 5 in the pink link and in the black text below the box to 6, that would fix it.

Note from the Author or Editor:
The numeral "5" on top of the pink link inside the green box should be changed to "6", as per the reader's suggestion.

Anonymous  Sep 20, 2011  May 22, 2015
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 22
Figure 2-1

</order) should be </order>;
<invoice) should be </invoice>

Note from the Author or Editor:
In the diagram 2.1 where the customer figure talks to the waiter figure, the final character in each speech bubble is a standard closing bracket )

It should be a closing angle bracket >

Dmitry  Jan 22, 2017 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 37
5th paragraph

staring

should be

starting

Note from the Author or Editor:
Page 37 - replace "staring" with "starting"

Stephen Souness  Jun 21, 2016 
Printed, PDF, , Other Digital Version
Page 48
Just above the 'NOTE' column

It goes:
...
to extract information from request payloads. Using the requestWriter, we're able to
compute response messages for the consumer.

but 'requestWriter' should be 'responseWriter' instead.

Note from the Author or Editor:
Page 48: the phrase:

"Using the requestWriter, we're able..." must be changed to "Using the responseWriter, we're able"...

M.Tk  Feb 18, 2011  May 22, 2015
Printed
Page 48
Just above the 'NOTE' column

This is an errata for the errata. The correction given at http://oreilly.com/catalog/errata.csp?isbn=9780596805838 says:

"Using the requestWriter, we're able..." must be changed to "Using the reesponseWriter, we're able"...

There's a typo here - it should ne "responseWriter" not "reesponseWriter"

Note from the Author or Editor:
This has been fixed.

Andy Wilson  May 04, 2012  May 22, 2015
Printed, PDF, , Other Digital Version
Page 64
Example 4-7

I wonder whether a <status/> field is missing in Ex 4-7. Maybe
<status>paid</status>?

Note from the Author or Editor:
This is an accurate error. Example 4-7 should read:

HTTP/1.1 200 OK Content-Length: 241 Content-Type: application/xml Date: Wed, 19 Nov 2008 21:48:10 GMT
<order xmlns=&#8242;&#8242;http://schemas.restbucks.com/order&#8242;&#8242;> <location>takeAway</location> <items>
<item> <name>latte</name> <quantity>1</quantity> <milk>whole</milk> <size>small</size>
</item> </items>
<status>paid</status>
</order>

Anonymous  May 24, 2011  May 22, 2015
Printed, PDF, , Other Digital Version
Page 67
Code example

Example 4-12 should be able to throw different exceptions to represent an order being not found and some other internal server error. However the line throw new WebApplicationException(Response.Status.NOT_FOUND) is inside a try-block which will catch and rethrow, so it's impossible for a not-found-error to escape.

Note from the Author or Editor:
Example 4-12 should be changed to read exactly as follows:

@Path("/order")
public class OrderingService {
@GET
@Produces("application/xml")
@Path("/{orderId}")
public String getOrder(@PathParam("orderId") String orderId) {

Order order = OrderDatabase.getDatabase().getOrder(orderId);

if (order == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
} else {
try {
return xstream.toXML(order);
} catch (Exception e) {
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
}
// Remainder of implementation omitted for brevity
}

Craig P. Motlin  Aug 15, 2011  May 22, 2015
Printed, PDF, , Other Digital Version
Page 69
1st Paragraph

"In accordance with the HTTP specification, a successful PUT request won�t create a new resource or produce a new URI."

PUT can create a new resource.

From http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6

"If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI."

Note from the Author or Editor:
It would be a good clarification to change this sentence:

"In accordance with the HTTP specification, a successful PUT request won�t create a new resource or produce a new URI. Instead, the state of the identified resource will be updated to reflect the data in the request representation."

to

"In this case, a successful PUT request won�t create a new resource but will instead update the state of the identified resource to reflect the data in the request representation."

Greg Moulliet  Jun 09, 2011  May 22, 2015
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 82
Example 4-29

<status>pending</preparing> -- not sure if the content should be "pending" or "preparing", but the end tag </preparing> is definitely wrong and should be replaced with a </status> tag.

Note from the Author or Editor:
Please replace figure 4-29 as follows:

PUT /order/1234 HTTP/1.1
Host: restbucks.com
If-Match: "72232bd0daafa12f7e2d1561c81cd082"

<order xmlns="http://schemas.restbucks.com/order"">
<location>takeAway</location>
<items>
<item>
<milk>skim</milk>
<name>cappuccino</name>
<quantity>2</quantity>
<size>large</size>
</item>
</items>
<status>pending</status>
</order>

Ken A Collins  Dec 23, 2012  May 22, 2015
Printed, PDF, , Other Digital Version
Page 99
In the @Path explanation after example 4-12

URI template {/orderId} should be /{orderId}

Note from the Author or Editor:
p.67 print edition, last bullet point: {/orderId} should be /{orderId}

Arjan Moraal  Oct 02, 2010  May 22, 2015
Printed, PDF, , Other Digital Version
Page 105
Example 5-5

The last end-tag should be </order> instead of </entry>.

Note from the Author or Editor:
Example 5-5 needs to be changed to be as follows:

<order xmlns=&#8242;&#8242;http://schemas.restbucks.com&#8242;&#8242;>
<location>takeAway</location>
<item>
<name>latte</name>
<quantity>1</quantity>
<milk>whole</milk>
<size>small</size>
</item>
<cost>2.0</cost>
<status>payment-expected</status>
<link rel="http://relations.restbucks.com/payment"
href="https://restbucks.com/payment/1234"/>
<link rel="http://relations.restbucks.com/special-offer"
href="http://restbucks.com/offers/cookie/1234"/>
</order>

Kun Lee  Jul 23, 2011  May 22, 2015
Printed, PDF, , Other Digital Version
Page 117
Example 5-6

The link:
<dap:link mediaType="application/vnd.restbucks+xml"
uri="http://restbucks.com/order/1234" rel="self" />

should be replaced with:
<dap:link
uri="http://restbucks.com/order/1234" rel="self" />

The mediaType attribute should not be there, because a sentence on page 116 reads:
"If a request does not require an entity body, the mediaType attribute will be absent".

If I have understood correctly, the mediaType attribute should also be removed from other links:
... rel="http://relations.restbucks.com/cancel" ... on page 116
... rel="http://relations.restbucks.com/order" ... on page 118
... rel="http://relations.restbucks.com/receipt" ... 2 occurrences on page 118
... many other occurrences on the following pages

As I understand it, the GET and DELETE requests don't require an entity body.

There are also minor mistakes:
<ns2:payment should be <payment (example 5-8, on page 118)

rel=http://relations.restbucks.com/self should be rel="self" (example 5-15, page 123)

Note from the Author or Editor:
Please change this paragraph:

----
If a request requires an entity body, the link element will contain a mediaType attribute that declares the format of the request payload. If a request does not require an entity body, the mediaType attribute will be absent.
----

To this, maintaining the formatting of code in paragraph.

----

If a request requires an entity body, the link element will contain a mediaType attribute that declares the format of the request payload. If a request does not require an entity body, and no other domain application protocol semantics need to be conveyed the mediaType attribute may be absent.

----

Mateusz Zakrzewski  May 05, 2012  May 22, 2015
Printed, PDF, , Other Digital Version
Page 124
Example 5-17

The end-point for the POST request should be /payment/coffee-card/1234 as advertised by the coffee-card-payment URI on the resource representation shown in example 5-16 (same page).

Note from the Author or Editor:
Please change Example 5-17 to read exactly as follows:


POST /payment/coffee-card/1234 HTTP/1.1
Host: restbucks.com
Content-Length: 270
Content-Type: application/vnd.restbucks+xml
Date: Sun, 21 Mar 2010 19:08:22 GMT

<coffeeCard xmlns="http://schemas.restbucks.com">
<link rel="http://relations.restbucks.com/self"
href="http://restbucks.com/coffeecard/4456afd23">
<tamperProof>19590f1ed86f3b2ecaf911267067e8a8</tamperProof>
<numberOfCoffees>9</numberOfCoffees>
</coffeeCard>

Thiago Arrais  Jun 15, 2012  May 22, 2015
PDF
Page 131
Figure 5-10

in Order Resource image, 'UpadateOrderActivity' -> 'UpdateOrderActivity'

Note from the Author or Editor:
Thank you for spotting this. "UpadateOrderActivity" should be changed to "UpdateOrderActivity".

Paul Roebuck  Sep 30, 2010  May 22, 2015
Printed, PDF,
Page 131
Figure 5-10

In Figure 5-10, box on top right, I think uri should be /order/{orderId} instead of /receipt/{orderId}.

Note from the Author or Editor:
In figure 5-10 the light orange box on the far right, second from the top is currently labeled "/receipt/{orderId}"

This is wrong and is a bug introduced when O'Reilly had the figures for the book needlessly redrawn (the originals were accurate and visually more appealing than the O'Reilly house style).

Please change that box so it reads:

/order/{orderId}

Arjan Moraal  Oct 09, 2010  May 22, 2015
Printed, PDF, , Other Digital Version
Page 149
Example 5-31

PaymendReceived should be PaymentReceived

Note from the Author or Editor:
Change the line in Example 5-31 that reads:

PUT PaymendReceived 201 => PaymentReceived

to read:

PUT PaymentReceived 201 => PaymentReceived

Please maintain formatting.

Craig P. Motlin  Aug 30, 2011  May 22, 2015
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 177
Paragraph starting as "These Cache Control directives allow ..."

In the Paragraph starting as "These Cache Control directives allow ...", in the sentence "Consumers that require a higher degree of consistency can use max-age or min-stale to obtain representations with stricter freshness bounds ...", I believe "min-stale" should be "min-fresh".

Note from the Author or Editor:
All occurrences of the text `min-stale` should be replaced with the text `min-fresh`

Tai Tse  Nov 27, 2015 
Printed, PDF, , Other Digital Version
Page 210
Example 7-7

I think this piece of code

if (validStartAndEndEntries(startPos, endPos)) {
// Bad URI - the paramters don't align with our feeds
return Response.status(Status.NOT_FOUND).build();
}

should be

if (!validStartAndEndEntries(startPos, endPos)) {
// Bad URI - the parameters don't align with our feeds
return Response.status(Status.NOT_FOUND).build();
}

because it should return a 404 when the URI is invalid.

Note from the Author or Editor:
Example 7-7 should read:

@GET
@Path("/{startPos},{endPos}")
@Produces("application/atom+xml")
public Response getSpecificFeed(@PathParam("startPos") int startPos, @PathParam("endPos") int endPos) {

if (invalidStartAndEndEntries(startPos, endPos)) {
// Bad URI - the paramters don't align with our feeds
return Response.status(Status.NOT_FOUND).build();
}

if(workingFeedRequested(startPos)) {
return getWorkingFeed();
}

EventFeedGenerator generator = new
EventFeedGenerator(uriInfo.getRequestUri(), ENTRIES_PER_FEED);
Feed feed = generator.feedFor(startPos);
return Response.ok().entity(stringify(feed)).header(CACHE_CONTROL_HEADER,
cacheDirective(CachePolicy.getArchiveFeedLifetime()))
.type(ATOM_MEDIA_TYPE).build();
}

private Response getWorkingFeed() {
EventFeedGenerator generator = new
EventFeedGenerator(uriInfo.getRequestUri(),
ENTRIES_PER_FEED);
Feed feed = generator.getWorkingFeed();

return Response.ok().entity(stringify(feed))
.header(CACHE_CONTROL_HEADER,
cacheDirective(CachePolicy.getWorkingFeedLifetime()))
.type(ATOM_MEDIA_TYPE).build();
}

Kun Lee  Aug 06, 2011  May 22, 2015
Printed, PDF, , Other Digital Version
Page 217
First paragraph

The product and region elements are in the http://www.w3.org/2005/Atom namespace while they belong in the http://schemas.restbucks.com/promotion namespace. The elements <ns2:product ..> and <ns2:region .. > should be replaced by <product ..> and <region ..>.

The attribute "xmlns:ns2" on the parent promotion element on page 216 is thereby unnecessary and can be removed.

Note from the Author or Editor:
Example 7-16 should be changed to read exactly as follows (maintaining all bold formatting):


HTTP/1.1 200 OK
server: grizzly/1.8.1
Cache-Control: max-age=2592000
Content-Type: application/atom+xml


<entry>
<title>product</title>
<link rel="self"
href="http://restbucks.com/product-catalog/notifications/notifications/120" />
<link rel="related" href="http://restbucks.com/products/2012703733" />
<category term="product"
scheme="http://restbucks.com/product-catalog/notifications/categories/type" />
<category term="new"
scheme="http://restbucks.com/product-catalog/notifications/categories/status" />
<id>tag:restbucks.com,2009-08-15:120</id>
<updated>2008-04-04T16:24:02Z</updated>
<content type="application/vnd.restbucks+xml">
<product xmlns="http://schemas.restbucks.com/product"
href="http://restbucks.com/products/2012703733">
<name>product name 543809053</name>
<price>2.34</price>
</product>
</content>
</entry>
<entry>
<title>promotion</title>
<link rel="self"
href="http://restbucks.com/product-catalog/notifications/notifications/148" />
<link rel="related" href="http://restbucks.com/promotions/1669488880" />
<category term="promotion"
scheme="http://restbucks.com/product-catalog/notifications/categories/type" />
<category term="new"
scheme="http://restbucks.com/product-catalog/notifications/categories/status" />
<id>tag:restbucks.com,2009-08-15:148</id>
<updated>2008-04-04T16:24:02Z</updated>
<content type="application/vnd.restbucks+xml">
<promotion xmlns="http://schemas.restbucks.com/promotion"
href="http://restbucks.com/promotions/1669488880">
<effective>2009-08-15</effective>
<product type="application/vnd.restbucks+xml"
href="http://restbucks.com/products/1995649500" />
<region type="application/vnd.restbucks+xml"
href="http://restbucks.com/regions/2140798621" />
</promotion>
</content>
</entry>

Stig Inge Lea Bj�rnsen  Sep 15, 2011  May 22, 2015
Printed, PDF, ePub
Page 286
Example 9-2

I think there is an typo in the HTTP header WWW-Authenticate. There is an 'u' missing. Same problem in example 9-4 on page 287.

Note from the Author or Editor:
Please change figure 9-2 to read:

401 Unauthorized
WWW-Authenticate: Basic realm=′′payments@restbucks.com′′

Anonymous  Feb 09, 2015  May 22, 2015
Printed, PDF, , Other Digital Version
Page 320
Figure 9-10

"comsumer" should be "consumer"

Note from the Author or Editor:
The text in the figure should change from "comsumer" to "consumer".

Anonymous  Jan 03, 2012  May 22, 2015
PDF, Other Digital Version
Page 359
Figure 10-2

URI http://restbucks.com/vocab#tsemi -> should be http://restbucks.com/vocab/#semi ?

Note from the Author or Editor:
The URI should indeed be "http://restbucks.com/vocab/#semi".

Arjan Moraal  Oct 13, 2010  May 22, 2015
PDF
Page 361
Figure 10-3

URL for currency should be "http://restbuck.com/vocab#uk-pounds" instead of "http://restbuck.com/vocab#latte".

Note from the Author or Editor:
Yes, this problem must have been introduced during the figure designs.

Jean-Luc Barras  Oct 19, 2010  May 22, 2015
Printed
Page 371
Example 10-16, Example 10-17, Example 10-18

There are errors in the Example 10-18.

Some of the highlighted RDF-a statements are supposed to mean:
"The whole milk's supplier is http://localfarmer.com"
"The recipe for a chocolate cookie is http://restbucks.com/recipes/choc-cookie"

but they actually mean:
"The supplier of the order (the current document) is http://localfarmer.com"
"The recipe for the order (the current document) is http://restbucks.com/recipes/choc-cookie"

The simplest fix would be to add:
- about="rv:milk" attribute to the "<milk>" element
- about="rv:kind" attribute to the "<kind>" element

There is one problem with this solution, however. It is not possible to represent an order with two items associated with two different milk suppliers. The better solution might be to leave "<milk>" and "<kind>" elements unchanged and add blank nodes associated with item elements like this:

<item about="[_:item1]">
<name>latte</name>
<quantity>1</quantity>
<milk rel="rv:supplier" href="http://localfarmer.com/">whole</milk>
<size>12</size>
</item>
<item about="[_:item2]">
<name>cookie</name>
<kind rel="rv:recipe" href="http://restbucks.com/recipes/choc-cookie">chocolate-chip</kind>
<quantity>2</quantity>
</item>


Propably there is one more problem with the Examples 10-17 and 10-18.
It seems that the "typeof" attribute in the line:
<cost property="rv:uk-pounds" typeof="xsd:decimal">12.0</cost>

is used incorrectly - the literal "12.0" is missing in the RDF. I used the following parser:
http://www.w3.org/2012/pyRdfa

The "typeof" attribute should be used when it refers to the type of the subject.
I think that here the "datatype" attribute should be used instead.

There is a similar problem in the Example 10-16.
The "typeof" attribute should be moved from the "span" element to the "p" element.


There is one more problem with the Example 10-16.
Some of the RDF triples have the following subjects:
- "restbucks:coupon-recipient"
- "restbucks:coupon-product"

The triples propably represent inconsistent information. If there are two coupons then the triples will be interpreted this way:
"The name of the http://restbucks.com/vocab#coupon-recipient is John Smith" (on first coupon)
"The name of the http://restbucks.com/vocab#coupon-recipient is George Smith" (on the second coupon)

We don't know what the name of the coupon-recipient is (the machine interpreting the RDF will assume that there is only one coupon recipient).

The recipients and products in different coupons should be identified by different URIs.

Note from the Author or Editor:
Example 10-18:
Replace first instance of <item> with <item about="[_:item1]">
Replace second instance of <item> with <item about="[_:item2]">

Example 10-17:
Replace
typeof=″xsd:decimal″
with
datatype="xsd:decimal"

Example 10-16:
Replace
typeof=″foaf:Person″
with
datatype=″foaf:Person″

Mateusz Zakrzewski  Sep 01, 2012  May 22, 2015
Printed, PDF, , Other Digital Version
Page 3362
Figure 5-7

Here, even after stating that POST will be used for updates to an order, this figure indicates using PUT. The authors clearly changed their minds along the way somewhere.

Note from the Author or Editor:
In Figure 5-7, change:

Update (PUT)

to

Update (POST)

Mike Williams  May 31, 2011  May 22, 2015
Printed, PDF, , Other Digital Version
Page 3568
Example 5-15

(Page number is Kindle location.)

Coffee card link should be rel="self"

Note from the Author or Editor:
Example 5-15 should read as follows:


HTTP/1.1 200 OK
Content-Length: 239
Content-Type: application/vnd.restbucks+xml
Date: Sun, 21 Mar 2010 19:07:33 GMT

<coffeeCard xmlns="http://schemas.restbucks.com">
<link rel="self"
href="http://restbucks.com/coffeecard/4456afd23">
<tamperProof>fff405268fea556a351459e7368bc1d3</tamperProof>
<numberOfCoffees>2</numberOfCoffees>
</coffeeCard>

Jay Mitchell  Nov 20, 2011  May 22, 2015
Printed, PDF, , Other Digital Version
Page 5171
Explanation of Example 7-1

<atom:generated> should be <atom:generator>. (Example 7-1 itself is correct.)

Note from the Author or Editor:
On page 188 (eBook at least) the string:

atom:generated

should be

atom:generator

Jay Mitchell  Nov 22, 2011  May 22, 2015