Closed mdewey closed 5 years ago
Wasnt sure where to find in the documentation how to specify the query to a specific species. Wrote what I think makes sense but I dont get a return of just the lion species object instead i get a return of all the animals. Tried some things but got 404 error and what I have so far at lease doesn't crash the page. Would like to find out what i'm missing.
I was able to create a new animal but wasn't thinking and pressed enter before entering data. so Animal with id: 6 has nil values.
I was able to see the json data in localhost but was not able to get a read from postman. Not sure what to make of that.
Take the Safari Online.
Let's Continue our safari adventure
We are taking a surprise trip to the Savannah for a safari to see all sorts of exotic animals. During our time their we want to keep track of all the animals we have seen. For this, we need to create an API to help record what we see.
Objectives
Requirements
For .NET Students, install the
sdg-api
template using the commanddotnet new -i SDG.templates.Web.API
Explorer Mode (C#)
[ ] Your database will be named called
SafariVacation
[ ] This will have 1 table called
SeenAnimals
that has the following columnsId
Species
CountOfTimesSeen
LocationOfLastSeen
NOTE: This should be made all in the code using
Entity Framework
and not created in thepgcli
.[ ] Your API should have the following endpoints:
GET /Animals
Endpoint that returns all animals you have seenGET /Search?species=lion
that returns all animals where the species name contains the species parameterPOST /Animal
endpoint that adds an animal to the database. THis should take a JSON bodyExplorer Mode (Ruby)
[x] Your rails application will be named called
safari_vacation
[x] This will have 1 model called
Animal
that has the following columnsspecies
(string)seen_count
(int)last_seen_location
(string)NOTE: This should be made using
rails generate model
and not created in thepgcli
.[x] Your API should have the following endpoints:
GET /animals
that returns all the animals as JSONGET /animals?species=lion
that returns all animals as JSON where the species name contains the species parameterPOST /animal
that adds an animal to the database. This should take a JSON bodyAdventure Mode (C#)
GET /Animal/{location}
that returns animals of only that locationPUT /Animal/{id}
endpoint that adds 1 to the count of times seen for that animal (given by id)DELETE /Animal/{id}
endpoint that deletes that animal id from the databaseLocation
be its own tableSearch
endpoint to search by an animal or by locationPUT /Animal/{animal}/{amount}
endpoint that adds{amount}
to that animalAdventure Mode (Ruby)
GET /animals?location={location}
that returns animals of only that locationPUT /animals/increment
that adds 1 to the count of times seen for that animal (given by id)DELETE /animals/{id}
endpoint that deletes that animal id from the databaseEpic Mode
Additional Resources
.NET
Here are the interesting commands you will need for tonight's assignment
NOTES: