learn more...Generally speaking, a REST request will involve sending a request to a special URL (similar to what you would see after filling out a form using the GET method), then receiving an XML document containing the server's response. The XML response is then parsed, and the desired information is extracted and acted upon. Each REST request generally has several common elements:
With those elements in mind, you can create a theoretical request:
http://library.example.com/api.php?devkey=123&action=search&type=book&keyword=style
Here a request is sent to the endpoint http://library.example.com/api.php, with a developer key of 123. The desired action is search, and type and keyword parameters are included with values of book and style. Given that request, the response would look something like this: <?xml version="1.0" encoding=" UTF-8"?> <Argument Name="keyword" Value=" style" /> You can see that the response has several structural elements. First, it declares itself to be XML 1.0 and uses UTF-8 for encoding. The LibraryAPI element is the root element of this document and includes the specified namespaces. Second, the Request section; it is common for REST requests to include all information sent with the request in the response. This adds clarity, and can ease programming on the requestor's end. Here you see each of the four elements passed to the service. Finally, looking a bit closer, you will notice that in this case the response has returned some metadata about the results, shown in the ResultCount tag, along with the result items themselves. For this request you see each book is encapsulated within an Item element, which has five children that describe specific attributes of the books. |
||||||
Disclaimer
1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here. link to this article |