#RestFul API explaination.
About RESTFul API
API
- Base url : http://........
- API design in RESTful with 4 method:
- GET to get resource(s)
- POST to create a new resource
- PUT to update resource. The PUT parameter must be provided by x-www-form-urlencoded or JSON format. If in JSON format, Request headers must have “Content-Type” is “application/json”
- DELETE to delete resource
Default response format is JSON, but you can change to: xml, json, serialize, php (raw output that can be used in eval), html, csv. To choose response format, xml for example, put “/format/xml” or “.xml” to the end of the url, for example: [base-url]/api/service/level/format/xml = [base-url]/api/service/member.xml
Return code
Restful API Status code:
- 200 (OK) confirms the success of a GET, PUT, or DELETE request.
- 201 (Created) confirms the success of a POST request.
- 304 (Not Modified) is used by a conditional GET to inform the client that the resource has not been modified.
- 400 (Bad Request) indicates a malformed request, often for a POST or PUT in which the request’s content is invalid.
- 401 (Unauthorized) is used to indicate that authentication is required.
- 403 (Forbidden) indicates that the client is not authorized for the requested action.
- 404 (Not Found) is used to respond to any request to indicate that the resource could not be found.
- 405 (Method Not Allowed) informs the client the that requested HTTP method is not available for that resource.
- 409 (Conflict) should be used for situations where there is a conflict which prevents the service to perform the operation, but there is still a chance that the client might be able to resolve the conflict and resubmit the request.