Session Ready
Exercise

POST requests in practice

Next we'll look at POST requests, also made through httr, with the function (you've guessed it) POST(). Rather than asking the server to give you something, as in GET requests, a POST request asks the server to accept something from you. They're commonly used for things like file upload, or authentication. As a result of their use for uploading things, POST() accepts not just a url but also a body argument containing whatever you want to give to the server.

You'll make a very simple POST request, just uploading a piece of text, and then inspect the output to see what it looks like.

Instructions
100 XP
  • Load the httr package.
  • Make a POST request with the URL http://httpbin.org/post and the body "this is a test", saving the result to post_result.
  • Print post_result to inspect it.