Request method explanation

FIRST LINE adopts RESTful as the main API design, and there are four HTTP request methods used:

Method

Description

GET

Request to display the specified resource, i.e., view data

POST

Used to submit the entity of the specified resource, i.e., create data

PUT

Replace the specified resource, i.e., update data

DELETE

Delete the specified resource, i.e., delete data

Request example

Below is using POST a Postman example demonstrating a request to create a customer

{
    "membership_no":"R0000555",
    "identity_no":"A000000002",
    "gender":0,
    "first_name":"Chen",
    "last_name":"Da-hua",
    "birth_at":"1990-01-01"
}

In Postman, it is recommended to select Body -> raw and enter JSON directly. This avoids Postman mistakenly converting numeric values to strings, which can cause some fields to fail validation.

Headers

There are three headers; each is explained below:

Headers

Description

Authorization

i.e., the token; you can also use a query string parameter as an alternative.

Content-Type

Ensures the server receives and returns data in JSON format, so this header is necessary.

Accept

To ensure the server receives and returns data in JSON format, this header is necessary.

Other methods

GET \ DELETE

GET,DELETE By analogy, choose the corresponding Postman request method.

PUT

Because direct HTTP PUT requests are not supported, when you need to perform a PUT request, use POST instead and be sure to include the parameter _method="put".

Postman illustration

Error codes

Use standard HTTP status codes, defined by RFC 2616 and extended by RFC 2518,RFC 2817,RFC 2295,RFC 2774 and RFC 4918 and other RFC extensions. All status codes are divided into five classes; the first digit of the status code represents one of the five response categories. The reason phrases shown are typical but any readable alternative may be provided. Unless otherwise noted, the status codes are part of the HTTP/1.1 standard (RFC 7231).

Code

Description

400

Bad Request - Your request is invalid.

401

Unauthorized -- Your API key is wrong.

403

Forbidden -- The kitten requested is hidden for administrators only.

404

Not Found -- The specified kitten could not be found.

405

Method Not Allowed -- You tried to access a kitten with an invalid method.

406

Not Acceptable -- You requested a format that isn't json.

410

Gone -- The kitten requested has been removed from our servers.

418

I'm a teapot.

419

Session expired.

422

Unprocessable Entity.

429

Too Many Requests -- You're requesting too many kittens! Slow down!

500

Internal Server Error -- We had a problem with our server. Try again later.

503

Service Unavailable

Last updated