Updated meta description for resources.html and restquicktips.html since they were duplicates.

This commit is contained in:
Todd Fredrich
2012-05-18 13:08:18 -06:00
parent 29c1df9b78
commit c4536a54c0
2 changed files with 4 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>HTTP Methods for RESTful Services</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="HTTP methods tutorial on how to use them for RESTful API or Web Service.">
<meta name="description" content="RESTful API or Web Service Quick Tips. Want to learn the high points of creating a REST API? Here's the Web Services in 60-seconds version.">
<meta name="author" content="Todd Fredrich, Pearson eCollege">
<!-- Le styles -->
<link href="https://d7im4lln3lvbg.cloudfront.net/bootstrap/2.0.1/css/bootstrap.min.css" rel="stylesheet">
@ -39,16 +39,14 @@
<div class="span12">
<h1>REST API Quick Tips</h1>
<p>Whether it's technically RESTful or not (according to the six constraints mentioned above), here are a few recommended REST-like concepts that will result in better, more usable services:</p>
<h2>Not SOAP</h2>
<p>There are legitimate reasons to have a SOAP API, and translating a massive API from a legacy SOAP to REST interface is quite difficult, but its incredibly difficult to consume SOAP if you have to develop a client library from scratch, access it via a Web UI, or do anything non-standard.</p>
<h2>Use HTTP Verbs to Mean Something</h2>
<p>Any API consumer is capable of sending GET, POST, PUT, and DELETE verbs, and they greatly enhance the clarity of what a given request does. Also, GET requests must not change any underlying resource data. Measurements and tracking may still occur, which updates data, but not resource data identified by the URI.</p>
<h2>Sensible Resource Names</h2>
<p>Having sensible resource names or paths (e.g., /posts/23 instead of /api?type=posts&id=23) improves the clarity of what a given request does. Using URL query-string parameters is fantastic for filtering, but not for resource names.</p>
<p>Having sensible resource names or paths (e.g., /posts/23 instead of /api?type=posts&amp;id=23) improves the clarity of what a given request does. Using URL query-string parameters is fantastic for filtering, but not for resource names.</p>
<p>Appropriate resource names provide context for a service request, increasing understandability of the service API. Resources are viewed hierarchically via their URI names, offering consumers a friendly, easily-understood hierarchy of resources to leverage in their applications.</p>
<p>Resource names should be nouns—avoid verbs as resource names. It makes things more clear. Use the HTTP methods to specify the verb portion of the request.</p>
<h2>XML and JSON</h2>
<p>Unless the costs of offering both JSON and XML are staggering, offer them both. Ideally, let consumers switch between them by just changing an extension from .xml to .json. In addition, for supporting AJAX-style user interfaces, a wrapped response is very helpful. Provide a wrapped response, either by default or for separate extensions, such as .wjson and .wxml to indicate the client is requesting a wrapped JSON or XML response. (see Wrapped Responses below).</p>
<p>Favor JSON support, but unless the costs of offering both JSON and XML are staggering, offer them both. Ideally, let consumers switch between them by just changing an extension from .xml to .json. In addition, for supporting AJAX-style user interfaces, a wrapped response is very helpful. Provide a wrapped response, either by default or for separate extensions, such as .wjson and .wxml to indicate the client is requesting a wrapped JSON or XML response.</p>
<p>JSON in regards to a "standard" has very few requirements. And those requirements are only syntactical in nature, not about content format or layout. In other words, the JSON response to a REST service call is very much part of the contract—not described in a standard. More about the JSON data format can be found at http://www.json.org/.</p>
<p>Regarding XML use in REST services, XML standards and conventions are really not in play other than to utilize syntactically correct tags and text. In particular, namespaces are not, nor should they be use in a RESTful service context. XML that is returned is more JSON like—simple and easy to read, without the schema and namespace details present—just data and links.</p>
<h2>Create Fine-Grained Resources</h2>