Now that we've got our API up and running in Azure, let's add some data so it's there, ready and waiting, for us to play with in Power Apps.
- Look for the
GET /lists
action under the Lists API.
- Expand the action and click Try it out.
- Then click Execute. This will execute that API action in order to get an array of ToDo lists in the application.
Scroll down to where you see the Server Response. You should see the 200 response code which means the execution was a success. You should also see the response body - which is the data that is returned to us after the action was executed.
Since this is your first time running the API, your response body will empty:
No worries - you'll be adding data in the next step.
Now you're going to be adding your own list.
-
Now look for the
POST /lists
action under the Lists API. -
Expand the action and click Try it out.
-
Replace the
Request body
with this:
{
"id": "c9c74ec076c245b195447f19cb3d6bbe",
"name": "Shopping",
"description": null
}
- Then click Execute.
Scroll down to where you see the Server Response. You should see the 201 response code which means the execution was a success (similar to 200) but in addition to that - 201 also means that a resource has been created. In this case, you have just created the Shopping ToDo list.
- Go back to the
GET /lists
action and execute that one more time.
In the server response, you'll now see that the Shopping ToDo list is returned.
Now you'll be adding ToDo items to the Shopping list.
-
Look for the
POST /lists/{listId}/items
action under the Items API. -
Expand the action and click Try it out.
This action is a little different because now you have a required parameter: listId
. Since you're going to be creating list items, the API needs to know which list to add the items to. Every list has a unique listId so that is how you're going to associate the list items with the correct ToDo list.
-
In the listId textbox, enter:
c9c74ec076c245b195447f19cb3d6bbe
(which is the id for the Shopping list) -
Replace the
Request body
with this:
{
"id": "dd181616c5a44b88815f5a98ec4699d1",
"listId": "c9c74ec076c245b195447f19cb3d6bbe",
"name": "Milk",
"description": null,
"state": "todo",
"dueDate": null,
"completedDate": null
}
- Then click Execute.
Scroll down to where you see the Server Response. You should see the 201 response code. Then scroll back up to the Request Body.
- Replace the
Request body
with this:
{
"id": "946b48331dce4904b413a96af034d83c",
"listId": "c9c74ec076c245b195447f19cb3d6bbe",
"name": "Bread",
"description": null,
"state": "todo",
"dueDate": null,
"completedDate": null
}
- Then click Execute.
Scroll down to where you see the Server Response. You should see the 201 response code. Then scroll back up to the Request Body.
- Replace the
Request body
with this:
{
"id": "e0394bfcfa4b4dc4b397d8c7e5aeaa85",
"listId": "c9c74ec076c245b195447f19cb3d6bbe",
"name": "Eggs",
"description": null,
"state": "todo",
"dueDate": null,
"completedDate": null
}
- Then click Execute.
Scroll down to where you see the Server Response. You should see the 201 response code.
You've now added 3 list items (milk, bread, and eggs) to the Shopping list - and you can prove it:
-
Look for the
GET /lists/{listId}/items
action under the Items API. -
Expand the action and click Try it out.
-
In the listId textbox, enter:
c9c74ec076c245b195447f19cb3d6bbe
(which is the id for the Shopping list). Then click Execute.
Scroll down to where you see the Server Response. You should see the 200 response code along with the 3 items that you've just added to the Shopping ToDo list.