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>From the comments i felt the need to explain this. </p>

<p><code>http://example.com/sth?key=value&amp;anotherkey=anothervalue</code></p>

<p>Let's assume  you have a url like the above in order to call with python requests you only have to write </p>

<pre><code> response = requests.get('http://example.com/sth', params={
                          'key':'value', 
                           'anotherkey':'anothervalue'
                         })
</code></pre>

<p>Have in mind that if your value or your keys have any special character in them they will be escaped thats the reason for the <code>%7B%2</code> part of url in your question. </p>

python python-requests