- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 125字
- 2021-07-03 00:02:19
Creating blog post
- Request: POST /posts HTTP/1.1
- Body parameters:
Content: This is an awesome post
Title: Awesome Post
- Response:
{id:1, title:"Awesome Post", content:"This is an awesome post", link: "/posts/1" }
- Response code: 201 Created
Here POST is the method, /posts is the URL (path after the server name) and HTTP 1.1 is the protocol. We will keep using the same way of mentioning requests in later examples as well. So, the first part of the request is the HTTP method, the second one is the URL and the third part is the protocol.
The response code tells the client that the resource has been created successfully. If a request parameter is missed by mistake, the response code should be 400, which represents a bad request.
推薦閱讀
- JavaScript從入門到精通(微視頻精編版)
- Progressive Web Apps with React
- NativeScript for Angular Mobile Development
- Full-Stack Vue.js 2 and Laravel 5
- Python漫游數學王國:高等數學、線性代數、數理統計及運籌學
- JavaScript:Moving to ES2015
- Mastering React
- 細說Python編程:從入門到科學計算
- Extending Unity with Editor Scripting
- Windows Phone 8 Game Development
- Python數據可視化之美:專業圖表繪制指南(全彩)
- 原型設計:打造成功產品的實用方法及實踐
- Python深度學習(第2版)
- 產品架構評估原理與方法
- Python 3.6從入門到精通(視頻教學版)