11.1. The JSON API for the Contact App
The API details:
The setup of the JSON API is exactly the same as the text API we used in App9. Just change the base URL. It'll work just fine.
The base URL:
https://apis.sakibnm.work:8888/contacts/json/
The endpoints:
Get all contacts:
getallMethod:
GETQuery Params: none
Get the details of a particular contact:
detailsMethod:
GETQuery Params:
name
Add a contact:
addMethod:
POSTBody Params:
name,email,phone.
Delete a particular contact:
deleteMethod:
GETQuery Params:
name
The only difference is that the response we will get from the API server is not plain String. They are JSON-formatted Strings.
For example,
getall:
https://apis.sakibnm.work:8888/contacts/json/getall
The response you should get is similar to the following:
details:
https://apis.sakibnm.work:8888/contacts/json/details?name=Alice Smith
The response should be:
If the contact is not found, the response should be:
delete:
https://apis.sakibnm.work:8888/contacts/json/delete?name=Alice Smith
The response should be:
If the contact is not found, the response should be:
add:
https://apis.sakibnm.work:8888/contacts/json/add [with POST body form]
If successful, you should receive something like the following:
If the contact is already there:
PLEASE test the API using Postman.
Last updated
Was this helpful?