From f2172922c51932bf2155a9fb4d7be6475002f32e Mon Sep 17 00:00:00 2001 From: Jonathan Drosdeck Date: Sun, 18 Mar 2012 15:37:46 -0400 Subject: [PATCH] Add quickstart doc and example for passing parameters in a GET request --- AUTHORS.rst | 1 + docs/user/quickstart.rst | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index c3d5005..243033f 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -89,3 +89,4 @@ Patches and Suggestions - Danver Braganza - Max Countryman - Nick Chadwick +- Jonathan Drosdeck \ No newline at end of file diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 3202ee6..70ec5f1 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -30,6 +30,32 @@ Let's get GitHub's public timeline :: Now, we have a :class:`Response` object called ``r``. We can get all the information we need from this. +Typically, you want to send some sort of data in the urls query string. +To do this, simply pass a dictionary to the `params` argument. Your +dictionary of data will automatically be encoded when the request is made:: + + >>> payload = {'key1': 'value1', 'key2': 'value2'} + >>> r = requests.get("http://httpbin.org/get", params=payload) + >>> print r.text + { + "origin": "179.13.100.4", + "args": { + "key2": "value2", + "key1": "value1" + }, + "url": "http://httpbin.org/get", + "headers": { + "Connections": "keep-alive", + "Content-Length": "", + "Accept-Encoding": "identity, deflate, compress, gzip", + "Accept": "*/*", + "User-Agent": "python-requests/0.11.0", + "Host": httpbin.org", + "Content-Type": "" + }, + } + + Response Content ---------------- -- 2.34.1