Cisco Cisco Prime Home 6.3 开发者指南

下载
页码 78
Cisco Prime Home – Integration Guide
 
 
OL-28558-01   v5.1
 
10 
API REFERENCE 
REST  
REST (REpresentational State Transfer) is a paradigm for interacting with a web 
service via the manipulation of data resources. In this paradigm, a URI represents a 
unique resource which can be manipulated using HTTP methods such as GET and 
POST. The state of the resource is transferred between the client and server as a 
representation of that resource which can be manipulated.  
Anatomy of a REST Call 
 
Request 
POST /person/bjones HTTP/1.1  
Host: people.mydomain.com  
Accept: application/json, text/xml;q=9, */*;q=8  
Content-Type: application/json  
 
{  
name: "Bob Jones",  
age: 30 
 
This request says: "Create a new resource at /person/bjones on 
people.mydomain.com using the provided JSON representation, and send the 
result back as JSON (or possibly XML, or maybe something else entirely) 
 
An HTTP request is ALWAYS in the form:  
[VERB] [resource uri] [http version]  
[headers] 
[\n]  
[body] 
 
This line indicates 3 things: the method, the URI of the resource, and the HTTP 
version. These things always appear like this as the first line of any HTTP request 
and are always followed by request headers.  
Headers 
Host: people.mydomain.com  
This header is always required when using HTTP version 1.1 and indicates which 
host or virtual host to request the resource from.  
Accept: application/json, text/xml;q=9, /;q=8  
This header informs the server how the client would like the representation of 
the resource to be formatted. It indicates both which formats the client accepts 
and their order of preferences. In this example, the client primary wants JSON 
formatted data. If that is not available, then XML would be alright too. If neither 
of those are available, just send the data in any format. 
  
 for more details.