From the course: Learning the Go Standard Library

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Performing HTTP POST

Performing HTTP POST - Go Tutorial

From the course: Learning the Go Standard Library

Start my 1-month free trial

Performing HTTP POST

- [Instructor] All right, so now that we've seen how to perform a GET operation, let's try performing an HttpPost. So, here in my example folder, let's open httppost_start. And similar to the HttpGet example, there's an empty function that we're going to fill out. And I've defined this url that will access the post endpoint at httpbin.org, the testing site that we've been using. And we'll try posting some data to that endpoint using a couple of different Go functions. So, first, I'm going to uncomment the imports that I'm going to need. Let's go ahead, and I know I'm going to need fmt, I'm going to need http. Okay. So, let's go ahead and take a look at the docs for the package one more time. All right, so here we are in the docs for the http package. And if we scroll down to the post function that's in the Response type, where is that? It's right here. So, this is what we can use to post data to an endpoint. And…

Contents