

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: HTTP Methods - GET
incomplete
2: Why Use HTTP Methods?
incomplete
3: POST Requests
incomplete
4: Status Codes
incomplete
5: Status Code Property
incomplete
6: HTTP PUT
incomplete
7: Patch vs. PUT
incomplete
8: Delete
incomplete
This lesson's interactive features are locked, please to keep using them
The HTTP PUT method creates or more commonly, updates the target resource with the contents of the request's body. Unlike GET and POST, there is no http.Put function. You will have to create a raw http.Request that an http.Client can Do.
While POST and PUT are both used for creating resources, PUT is more common for updates and is idempotent, meaning it's safe to make the same request multiple times without changing the server state more than once. For example:
POST /users/bob (create bob user)
POST /users/bob (create duplicate bob user)
POST /users/bob (create duplicate bob user)
PUT /users/bob (create bob user if it doesn't exist)
PUT /users/bob (update bob user with the same data)
PUT /users/bob (update bob user with the same data)
Complete the updateUser and getUserById functions.
The updateUser function takes a baseURL, id and apiKey string, and data User as input. It returns a User and error. It should:
getUserById takes a baseURL, id and apiKey string. It returns a User and error. It should:
We've included the fullURL creation logic for you in both functions, we'll be talking more about URL building in the next chapter.