0

Here's the API.

This is my first time working with web APIs so bear with me. Where do the name-value pairs listed under each call belong in my HTTP request? Do they go in the URL, the headers, or the body? Is it different depending on if it's a GET request or a POST?

Are the answers to these questions true in general, i.e. for any web API?

JamesGold
  • 725
  • 1
  • 7
  • 23
  • 1
    possible duplicate of [How are parameters sent in an HTTP POST request?](http://stackoverflow.com/questions/14551194/how-are-parameters-sent-in-an-http-post-request) this should work the same for reddit as for any other web api. there are good answers in the linked question, hope this helps you. – Nathan Hughes May 30 '14 at 04:23

1 Answers1

0

Where do the name-value pairs listed under each call belong in my HTTP request?

In a GET, they're in the URL's query string. in a POST, they're in the request body. Headers never contain request parameters, but things like Content-length do control them, a bit. You might also run across JSON in a POST body (I can't remember if reddit does this). This is not reddit-specific, and is standard HTTP.

David Ehrmann
  • 6,655
  • 1
  • 23
  • 33
  • At this time, just a few reddit API endpoints expect a JSON body. Specifically, [PATCH /api/v1/me/prefs](http://www.reddit.com/dev/api#PATCH_api_v1_me_prefs) and [PUT /api/v1/me/friends/{username}](http://www.reddit.com/dev/api#PUT_api_v1_me_friends_{username}) – kemitche Jun 02 '14 at 18:39