RESTful Web Services

Errata for RESTful Web Services

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date Submitted
Printed, ePub Page fXmmXAaymrt

BwwbCY <a href="">gngbiinimuar</a>, [url=]qulzakgwggdh[/url], [link=]hqulclaldpry[/link],

czwfip  Nov 30, 2016 
Printed Page 129
Example 5.6 last two links

The last two links with classes zoom_in and zoom_out have their link body exchanged. So the link with class "zoom_in" has the link text "Zoom out" and the link with class "zoom_out" has the link text "Zoom in" so instead of <a class="zoom_in" href="[...]">Zoom out</a> <a class="zoom_out" href="[...]">Zoom in</a> it should read <a class="zoom_in" href="[...]">Zoom in</a> <a class="zoom_out" href="[...]">Zoom out</a>

squiddle  Jul 11, 2013 
Printed Page 244
Example 8-4

If you run that script against a site that does not return ' Last-Modified' or 'Etag' values, you get a nasty crash (I had the case with First request: Status code: ["200", "OK"] Representation size: 90776 Last-Modified: Etag: Second request: G:/usr/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:1435:in `block in initialize_http_header': undefined method `strip' for nil:NilClass (NoMethodError) ... The solution is to check for nil when constructung your hash, something like: #!/usr/bin/ruby # fetch-oreilly-conditional.rb require 'rubygems' require 'rest-open-uri' uri = '' # Make an HTTP request and then describe the response. def request(uri, *args) begin response = open(uri, *args) rescue OpenURI::HTTPError => e response = end puts " Status code: #{response.status.inspect}" puts " Representation size: #{response.size}" last_modified = response.meta['last-modified'] etag = response.meta['etag'] puts " Last-Modified: #{last_modified}" puts " Etag: #{etag}" return last_modified, etag end puts "First request:" last_modified, etag = request(uri) puts "Second request:" # Build the hash, making sure it has no nil values hash = {} unless last_modified.nil? hash['If-Modified-Since'] = last_modified end unless etag.nil? hash['If-None-Match'] = etag end # ended building the hash request(uri, hash) ...and now we get: First request: Status code: ["200", "OK"] Representation size: 90488 Last-Modified: Etag: Second request: Status code: ["200", "OK"] Representation size: 95456 Last-Modified: Etag: ...instead of a crash. Running that same script against a site with proper return of ' Last-Modified' and 'Etag' values (say, we get: First request: Status code: ["200", "OK"] Representation size: 37614 Last-Modified: Wed, 20 Mar 2013 19:45:22 GMT Etag: "92ee-4d860766a9880;89-3f26bd17a2f00" Second request: Status code: ["304", "Not Modified"] Representation size: 0 Last-Modified: Etag: "92ee-4d860766a9880;89-3f26bd17a2f00" expected.

Varus Germanicus  Mar 20, 2013 
Printed Page 31
Example 2-4

On Windows: C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) I found that this is simply due to a lack of certificate authority in my Ruby installation. To solve this, you need to download a cacert.pem for RailsInstaller. It is all very well explained in Then the script in Example 2-4 did run just fine. Varus January 2013

Varus Septimus  Jan 22, 2013 
Printed Page 23

The Yahoo web search example does not work. Yahoo has discontinued the accessed service. I'm surprised I didn't see it mentioned already.

Terence Mark  Jan 17, 2012 
Printed Page 243
2nd code block

"compress" has an extra "s" in "Accept-Encoding: gzip,compresss"

Anonymous  Jan 03, 2012 
Printed Page 68
Example 3-20

I *think* there is an error in the signed_uri method. The "expires" variable is carefully set but never passed to the "signature" method (as the last argument) where it can be passed thru to "canonical_string" to set the Date: header. Yet on the next page (69) the need to override the Date: header with the "expires" time is emphasized with a direct reference to the code for "canonical_string" in Example 3-18. Either I missed something subtle or there's a mistake.

Mike Lutz  Feb 15, 2009 
Printed Page 2
Example 1-2

The very first example - Searching for books with a Ruby script - does not work with the code as is because the dependent library from has an updated version. Since the API has changed as well, in this new version (4?), getting the example to work for a new person to Ruby is hard. I made some approximations but I don't have it 100% right. I would appreciate if the updated code is po(a)sted here.

Anonymous  Jul 10, 2008 
Printed Page 6
Begining on 6th paragraph... and whole book

The authors use the term headers instead of header fields when refering to HTTP envelopes. I think they should stick to the RFC2616 terminology which is: a header is a block of header fields.

Printed Page 7
3rd paragraph

"This response has 11 headers" SHOULD BE "...10 headers"

Printed Page 31

I receive an authentication failure: Authentication fails. :/InstantRails/ruby/lib/ruby/1.8/net/http.rb:567: warning: using default DH parameters. C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:586:in `connect': certificate verify failed (OpenSSL::SSL::SSLError) from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:586:in `connect' (username and password is provided in lowercase without square brackets and with a space in between (no comma)) Code: See provides xml output <?xml version='1.0' standalone='yes'?> <tags> <tag count="1" tag="for:adobe" /> <tag count="1" tag="rails" /> <tag count="1" tag="restful" /> <tag count="2" tag="ruby" /> <tag count="1" tag="rubyonrails" /> <tag count="1" tag="system:unfiled" /> </tags> warning: peer certificate won't be verified in this SSL session This code also provides post by changing to posts/recent as in the example of page 31.

Printed Page 31
Example 2-4

Related code: response = open('', :http_basic_authentication => [username, password]) Error shown: c:/ruby/lib/ruby/1.8/net/http.rb:567: warning: using default DH parameters. c:/ruby/lib/ruby/1.8/net/http.rb:586:in `connect': certificate verify failed (Op enSSL::SSL::SSLError) from c:/ruby/lib/ruby/1.8/net/http.rb:586:in `connect' from c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start' from c:/ruby/lib/ruby/1.8/net/http.rb:542:in `start' On Windows XP, the ruby code does not work. Testing the api on safari browser and the authentication works.

Printed Page 56

You map the Amazon "Access Key ID" to @@public_key and the "Secret Access Key" to @@private key in your Authorized module.

Printed Page 109
Bottom list

The steps "4.) Expose a Subset of a Uniform Interface" and "5.) Design the Representations Accepted from the Client" are not supposed to be introduced until Chapter 6 p.148 (and are not discussed in Chapter 5). As a result later in Chapter 6 p148 the list is identical to p109 even though it is declared that two steps have been added.

Printed Page 119
3rd paragraph

This is very picky, but... after stating in the preceding paragraph that you would use comma to separate latitude and longitude, you go on to use a semicolon when you say: /v1/Earth/43.9;-103.46/Mount%20Rushmore would be more precise. Page 120 and 121 use commas, but page 123 uses a semi-colon (in the bullet points). Page 127 uses both in the same code sample at the bottom of the page. There are similar confusions up to at least page 139.

Printed Page 128
First image caption

Given the established convention of including the zoom level on the portion of the URI containing the map type, the caption for figure 5-1 on page 127 should be /road.3/Earth/images/37.0,-95.png instead of what is printed: /road/Earth.3/images/37.0,-95.png

Printed Page 128
3rd paragraph

Given the established convention of including the zoom level on the portion of the URI containing the map type, the URI in paragraph 3 on page 128 should be:,-95.png instead of what is printed:,-95.png Also, the zoom level should be 3 instead of 8 since this URI is meant to be referencing the example on the previous page. p.s. - In the body of the last error report I sent, I mentionded page 127 instead of the correct page for the error 128.

Printed Page 129
First image caption

The image caption for Figure 5-2 on page 129 has a typo. The URI should be /road.8/Earth/images/32.37,-86.30.png instead of /road.8/Earth/images/37.0,-95.png since the former is the example it is meant to illustrate as indicated in the text that follows.

Printed Page 129
First complete paragraph, third line

"32.37" -> "37.0" (twice) "86.30" -> "95" (twice) The coordinates given in the text are in Montgomery, AL, while the printed image claims to represent somewhere on the KS/OK border. (The image is not quite what I see on Google maps when I ask for 37N 95W, but at least it's plausible.)

Printed Page 131
example 5-8 xml example

The given xhtml is not well formed. For example the <li> tags are not closed properly.

Printed Page 131
Example 5-8

To confirm and add to an existing report: the XHTML is poorly formed. For example, the opening <dd> tag is missing for the "maps" unnumbered list.

Printed Page 133
Example 5-9

The "repeat" attribute on the input element (<input name="show" repeat="template") is astonishing to people familiar with (X)HTML. It gets explained on page 136 after it's used again, but it should be explained when first used.

Printed Page 136
Note at the bottom of the page

The note explains the use of the "repeat" attribute on (X)HTML input elements. While it's true that this is part of the nascent XHTML 5 specification, the documents in the book claim to be XHTML 1.1. Those that use features introduced in XHTML 5 are not valid XHTML 1.1. The note makes it clear that this is a convenient shorthand; it should also point out that the resulting documents are not useful in the real world. (In fact, they should never be, as written; they'll need to be modified to use the XHTML 5 doc type once it exists.)

Printed Page 152
Example 6-2

I think "CGI::escape("password=#{password}") should be whatever the Ruby syntax is for "password=" concatenated with CGI::escape("#{password}"). The note that follows says that the password is form- encoded, which is the correct behavior. If the equals sign is form-encoded, the server will see a name that includes an encoded equals sign instead of a name=value pair.

Printed Page 153
Example 6-3

'<input class="password"' -> '<input type="password"' '<input class="submit"' -> '<input type="submit"'

Printed Page 163
Last line

'<input class="submit" />' -> '<input type="submit" />' script/plugin install acts_as_taggable may install a version of the acts_as_taggable plugin that is broken. Use script/plugin install instead to obtain a version that works with Rails 1.2.6. It seems that the acts_as_taggable plugin has been deprecated.

Printed Page 172

"Finally, the __bundles__ API, which lets the authenticated user group similar tags together." "bundles/" would be more consistent with the context

Printed Page 182
3rd Paragraph; Example 7-3

ruby/ch7/service/config/routes.rb is missing in source archive

Printed Page 184
1st paragraph

The book states of page 183, there would be a form encoded request parameter such as: user[name]=leonardr&user[full-name]=Leonard%20Richardson it then states this would end up being parsed into: { "user[name]" => "leonardr", "user[full_name]" => "Leonard Richardson" } when in fact.. it would be parsed as: { "user" => {"name" => "leonardr", "full_name" => "Leonard Richardson"} Thus.. the syntax params[:user][:name] (shown in the code for the users controller on page 196) makes sense. The print listing, would not actually "work" if that was the actual data structure

Printed Page 192
Example 7-10. application.rb continued: if_found.

The "user_id_from_username" filter was not mentioned anywhere in the book. This should be "must_specify_user".

Printed Page 196
Third line of Example 7-13

The "<screen>" element appears to be a mistake. It's never closed, and I couldn't find any such element in the Atom spec.

Printed Page 197
Middle of the second paragraph

"(defined in the User) model)" -> "(defined in the User model)"

Printed Page 199
End of the last paragraph of text

"index and show simply delegate to the show_bookmarks action" does not agree with the code. While index calls show_bookmarks, show actually (and somewhat perversely) calls render_bookmarks.

Printed Page 233
3rd paragraph under URI Design

"Use semicolons when the order doesn't matter: /color-blends/red;blue." The use of semicolons to separate unordered parameters in a URI causes IE to strip the parameters off ServletRequestImpl.pathInfo starting at first semicolon. The remainder of the string is moved to the ServletRequestImpl.pathParameter field, so semicolons should either be avoided or used with a caveat.

Printed Page 245
"Printed" output for two requests, near the middle of the page

The response to the second request has a different Etag than the first. Since the second response indicates that the entity was not modified, shouldn't the tags be the same? In a testing with a few Web sites, I found that the Etag in a 304 response always matched the Etag in the request.

Printed Page 292-4
Example 9-10, 9-12

The example wadl file for uses a mix of two different wadl specifications: 20061109 (https:// and 20060802 ( The example does not validate with either schema. The application has the namespace for the earlier version, but the "header" value for param node's "style" attribute is not defined in this version. It is used in example 9-10. For the later revision, "header" is defined, but the "style" attribute is required for all params. The param in example 9-12 would need a "style" attribute.

Printed Page 341
Second bulleted item

"app/view/welogs/new.rhtml" -> "app/view/weblogs.rhtml"