This is an api that is used in Backend Mod 3 exercise for students to explore api tools including Postman and Faraday.
Rails 5.2.8.1
Ruby 2.7.4
-
Using Postman, try to get a successful response from each endpoint.
- If you haven't installed Postman you can do so here
-
Using Faraday, try to get a successful response from each endpoint.
- Install the Faraday gem
- Create a ruby file and require the Faraday library along with a debugger, such as pry
- In this newly created Ruby file write requests for each endpoint, use your debugger to check the response body
Extra Challenge: Explore how to parse a JSON response here
Example Response
[
{
"id": 1,
"name": "Wile E.",
"animal_type": "coyote",
"age": 4,
"created_at": "2020-05-05T14:41:55.013Z",
"updated_at": "2020-05-05T14:41:55.013Z"
},
{
"id": 2,
"name": "Road Runner",
"animal_type": "bird",
"age": 1,
"created_at": "2020-05-05T14:41:55.021Z",
"updated_at": "2020-05-05T14:41:55.021Z"
},
{
"id": 3,
"name": "Tweety",
"animal_type": "bird",
"age": 15,
"created_at": "2020-05-05T14:41:55.028Z",
"updated_at": "2020-05-05T14:41:55.028Z"
},
{
"id": 4,
"name": "Sylvester",
"animal_type": "cat",
"age": 2,
"created_at": "2020-05-05T14:41:55.037Z",
"updated_at": "2020-05-05T14:41:55.037Z"
}
]
Example Response
{
"id": 1,
"name": "Wile E.",
"animal_type": "coyote",
"age": 4,
"created_at": "2020-05-05T14:41:55.013Z",
"updated_at": "2020-05-05T14:41:55.013Z"
}
Request Example with required body
POST https://turing-pets-api.herokuapp.com/pets
body: {
"name": "Bugs",
"animal_type": "bunny",
"age": 5
}
Example Response
{
"id": 5,
"name": "Bugs",
"animal_type": "bunny",
"age": 5,
"created_at": "2020-05-05T14:41:55.013Z",
"updated_at": "2020-05-05T14:41:55.013Z"
}
Example Response
204 No Content
Example Request with body
PATCH https://turing-pets-api.herokuapp.com/pets/3
body: {
"age": 10
}
Example Response
{
"id": 3,
"name": "Tweety",
"animal_type": "bird",
"age": 10,
"created_at": "2020-05-05T14:41:55.028Z",
"updated_at": "2020-05-05T17:43:10.736Z"
}