Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Pranjal Agnihotri
Pranjal Agnihotri
4,187 Points

Internet Communication

I have got two questions?

  1. What are the other methods except GET/POST on HTTP.
  2. What does a Payload means??

1 Answer

Ari Misha
Ari Misha
19,323 Points

Hiya there! HTTP is a platform where everything magical happens but its also stateless. But with the help of RESTful API, we can now implement a system where we can send a request to execute requests on end-points. Request is simply an object literal containing all kinds of information, like what kind of request of it is including payload, or headers etc. Mostly request can be either GET or POST. GET is simply for fetching something from resource. Whereas POST is for adding some data to the resource. But there are actually 4 requests types. And other types are PUT/PATCH and DELETE. PUT is simply for updating something which already exists on resource, whereas DELETE is, as name suggests, deleting something from the resource.

Now, most of the time you'll only encounter either GET or POST. But in real world applications, you're gonna have to implement a back-end for all 4 requests types and response for the same request types. Now, response mostly contains status code, the format you asked for (like it can be json or xml or fragments of HTML etc.), messages and headers. Im pretty sure you've stumbled on to a uri something like this:

www.example.com/articles?id=2&&author=John

Now, see the pattern after ? (question mark), this is what we call Payload. Payload is simply the addtional information provided by the user in order to perform query on the resource. In above uri, its a GET request. How do i know that? Simply coz only GET request contains payload/query string in the uri. Whereas POST request contains sensitive data , which gets sent in the body of request object. BTW when i say resource , i mostly mean the database or Model layer or View-Model.

~ Ari

Pranjal Agnihotri
Pranjal Agnihotri
4,187 Points

Thanks Ari for a good and detailed explanation.By the way what does stateless means in HTTP

Ari Misha
Ari Misha
19,323 Points

Pranjal Agnihotri Stateless simply means that HTTP isnt aware of the state of the request or response, like every request is a new, fresh one for HTTP. Like 5-6 years ago, for multiple requests to back-end , you've to refresh the page everytime. But tech stacks like AJAX emerged which changed everything. Nowadays, you can make multiple requests to the back-end at the same time.