Python Requests - add text at the beginning of query string
<p>When sending data through python-requests a GET request, I have a need to specifically add something at the beginning of the query string. I have tried passing the data in through dicts and json strings with no luck.</p>

<p>The request as it appears when produced by requests:</p>

<pre><code>/apply/.../explain?%7B%22......
</code></pre>

<p>The request as it appears when produced by their interactive API documentation (Swagger):</p>

<pre><code>/apply/.../explain?record=%7B%22....
</code></pre>

<p>Where the key-value pairs of my data follow the excerpt above.</p>

<p>Ultimately, I think the missing piece is the <strong>record=</strong> that gets produced by their documentation. It is the only piece that is different from what is produced by Requests.</p>

<p>At the moment I've got it set up something like this:</p>

<pre><code>import requests
s = requests.Session()
s.auth = requests.auth.HTTPBasicAuth(username,password)
s.verify = certificate_path

# with data below being a dictionary of the values I need to pass.
r = s.get(url,data=data)
</code></pre>

<p>I am trying to include an image of the documentation below, but don't yet have enough reputation to do so:</p>

<p><a href="http://i.stack.imgur.com/r7Z5x.png" rel="nofollow">apply/model/explain documentation</a></p>

<p>'GET' requests don't have data, that's for 'POST' and friends.  </p>

<p>You can send the query string arguments using <code>params</code> kwarg instead:</p>

<pre><code>&gt;&gt;&gt; params = {'record': '{"'}
&gt;&gt;&gt; response = requests.get('http://www.example.com/explain', params=params)
&gt;&gt;&gt; response.request.url
'http://www.example.com/explain?record=%7B%22'
</code></pre>

python python-requests