⚠️ This lesson is retired and might contain outdated information.

Use HTTP POST Method

Pete Johanson
InstructorPete Johanson
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 2 years ago

The HTTP POST method is used to request the resource process the included request message body representation according to resource specific semantics. HTTP POST is loosely defined by definition, and can be used in many different scenarios, such as creating a new resource based on the request representation, appending data to an existing representation, or generic processing of an HTML form submission. Due to the nature of POST performing arbitrary resource specific processing, it is considered neither ‘safe’, nor ‘idempotent’.

[00:00] The HTTP post method is used to perform resource-specific processing of requests. This means it can actually be used in a variety of ways. Let's take a look at the first example, where post can be used to create a new resource. We'll be creating a new GitHub issue using the GitHub API.

[00:17] Here, we can see our post request has included a message body and a content type to indicate what is included in our request. This is optional with post requests, and some post requests may not have any message body at all.

[00:36] We can see that the GitHub server has responded with a 201 status code, indicating it has successfully created our new issue, and it's indicated the location of that issue, as well as returning a representation of that issue in the response. Post can also be used for other generic request processing. As an example, let's update the assignees of our created GitHub issue.

[01:10] Again, we have a request body indicating the assignees we would like to add to our issue. We can see that yet again, the GitHub API has responded with a 200 family status code, as well a location header indicating where our issue is that has been updated. We can also see that the issue itself has been updated to include a new assignee.

[01:29] Post requests are not idempotent. We can imagine that our initial request to create our issue, if retried several times, would end up creating multiple duplicate GitHub issues.

[01:39] To summarize, HTTP post is used to request resource-specific processing of our request. That can be used to create new resources, or to update or make modifications to existing ones, or request other generic processing.

egghead
egghead
~ 21 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today