Now that we've added a URL for our feed API let's go ahead and test it in the browser. Open up the
terminal or git bash window and make sure you've activated the virtual environment and that your development
server is up and running. Then open up google chrome and ensure that our authentication token is still
set in the mod headers chrome extension and head over to the URL of our API which is 127.0
0.0.1 : 8000 forward slash API.
Once the page loads you can see that there is a new feed item added to the list of our API root.
This is the feed API that we created previously.
So click on that and it should take you to this empty feed list.
Now this is where we can create and modify status updates for our user.
So if we add a new status text and we'll just write test status for this one and hit post you can see
that it goes and creates a new status update for us and returns the object in the browser. So you can
see that it created a new object with the I.D. one and it assigned it to the user profile one because
that is the user that we are currently authenticated with.
Okay.
So what if we wanted to modify this.
Well let's test the HTTP put and patch methods on this API.
So add the primary key ID which is the ID field of the object that was just created to the end of
the URL of our feed endpoint and hit enter.
This will take us to the page where we can modify or perform HTTP put or HTTP patch requests
on our object.
So if we want to perform a put
we simply just modify the text here.
So let's say we change this to test status to and hit put
you can see that the status text changes for this object if you want to test the patch you have to do
this in the raw data tab.
So we'll remove all of these
read only fields and then we'll just leave the status text and we'll just change this to test status 3 and
we'll hit patch.
Make sure that you remove the trailing comma here because otherwise it will be an invalid json object
and you'll get a validation error.
So once as all correct hit patch and you can see that it updates our profile object.
Okay so this all appears to be working.
Let's try and delete our object.
So hit delete and then this will make an HTTP DELETE request to our object and it will remove the
object.
And then if we go back to the root of the feed you can see that there are no items here.
Okay so this is when we're authenticated.
What happens if we try and create an object when we're not authenticated.
So let's uncheck the authorization in the mod headers chrome extension and then we're going to go ahead
and just refresh the feed page and let's create a new status, click on the HTML form and we'll
just put some test status text and then hit post.
You can see that because we are not authenticated
we got an uncaught exception raised.
So this is an error and this is because you cannot assign the anonymous user object to the user profile
of the feed item.
So this indicates that there are a few more changes that we need to make to our API view set in order
to handle this case and ensure that we never see an error like this in our API.
So we're going to be doing that in the future videos.
That's how you test the feed in the browser and I'll see you in the next video.