- 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.
推薦閱讀
- ClickHouse性能之巔:從架構(gòu)設(shè)計解讀性能之謎
- 國際大學(xué)生程序設(shè)計競賽中山大學(xué)內(nèi)部選拔真題解(二)
- 高效微控制器C語言編程
- 青少年美育趣味課堂:XMind思維導(dǎo)圖制作
- 趣學(xué)Python算法100例
- Servlet/JSP深入詳解
- Building a Recommendation Engine with Scala
- Python貝葉斯分析(第2版)
- Bootstrap 4:Responsive Web Design
- MATLAB 2020從入門到精通
- R語言與網(wǎng)絡(luò)輿情處理
- C語言程序設(shè)計實驗指導(dǎo) (第2版)
- Orleans:構(gòu)建高性能分布式Actor服務(wù)
- 深入理解BootLoader
- Python自然語言理解:自然語言理解系統(tǒng)開發(fā)與應(yīng)用實戰(zhàn)