From the course: Consuming RESTful APIs in Golang

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Making POST, PUT, and PATCH requests

Making POST, PUT, and PATCH requests - Go Tutorial

From the course: Consuming RESTful APIs in Golang

Making POST, PUT, and PATCH requests

- [Instructor] In this video we want to take a look at using the net HTTP package to perform HTTP requests of all the methods. So we want look at the post, the put, the delete, and patch methods. Essentially create a request for these different kinds of methods using the net HTTP package. In the previous videos we had already seen how to make a get request. Let's go over to the coding environment. So here we are, I have a simple coding example here that makes a post request using the package. As always, we start out with our import statements. In this particular example I am importing the bytes package, the context package, the format package, io package, Of course the main package here, which is the net/http package, and of course time. Follow along in this example and you see where they all fit. As always, I start out by creating my client. I set a three second time out. Then I specify my URL. Here is a very simple URL. I describe the payload I want to send with my post request. Now…

Contents