Resource representation
Resource representation defines the data format of the response. The response message may be in any one of the following formats:
- Plain text
- Form-encoding
- XML
- HTML
- JSON
- Any other Internet media type, provided that it is a valid hypertext standard
You can specify the format of the delivery content by setting the Content-Type header value in the request headers to the service. REST APIs commonly use either the application/json
or application/xml
media type.
Here is an example of a header request for JSON:
Content-Type: application/json Host: localhost:65437 Content-Length: 69
Now, we'll see an example for XML:
Content-Type: application/xml Host: localhost:65437 Content-Length: 69
Tip
Remember to use XML to transfer documents and JSON for data transfers.
推薦閱讀
- Java EE框架整合開發(fā)入門到實戰(zhàn):Spring+Spring MVC+MyBatis(微課版)
- Visual Basic編程:從基礎(chǔ)到實踐(第2版)
- Rust Cookbook
- Blender 3D Incredible Machines
- 快速念咒:MySQL入門指南與進(jìn)階實戰(zhàn)
- 深入理解Elasticsearch(原書第3版)
- Linux Shell核心編程指南
- OpenCV with Python By Example
- SQL Server 2008 R2數(shù)據(jù)庫技術(shù)及應(yīng)用(第3版)
- Practical GIS
- SAP Web Dynpro for ABAP開發(fā)技術(shù)詳解:基礎(chǔ)應(yīng)用
- 量子計算機(jī)編程:從入門到實踐
- 編程的原則:改善代碼質(zhì)量的101個方法
- Java 7 Concurrency Cookbook
- Splunk Essentials