<p dir="auto">The following code works in requests 2.7.0 but raises an assertion error in 2.8.0:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import requests

session = requests.session()
session.headers.update({'x-api-key': 'blah', &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;,
                              &quot;User-Agent&quot;: &quot;magnet-sdk-python&quot;})
session.verify = True
req = requests.Request(method='POST', url='https://portal.niddel.com/api/v1-beta/alerts', params=None, json={'a': 1, 'b': 2})
req = session.prepare_request(req)
assert req.body"><pre class="notranslate"><code class="notranslate">import requests

session = requests.session()
session.headers.update({'x-api-key': 'blah', "Accept-Encoding": "gzip, deflate",
                              "User-Agent": "magnet-sdk-python"})
session.verify = True
req = requests.Request(method='POST', url='https://portal.niddel.com/api/v1-beta/alerts', params=None, json={'a': 1, 'b': 2})
req = session.prepare_request(req)
assert req.body
</code></pre></div>
<p dir="auto">Since I provided neither <code class="notranslate">files</code> nor <code class="notranslate">body</code>, I would have expected <code class="notranslate">json</code> to work.</p>
<p dir="auto">In case you need this info to reproduce the issue, all tests were performed on a Mac OS X with Python 2.7.10 (installed using homebrew).</p>
<p dir="auto">In version <code class="notranslate">2.7.0</code> I was using <code class="notranslate">Requests</code> constructor with <code class="notranslate">json</code> parameter specified, like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="json_data = [ ... ];
r = requests.Request('POST', url, json=json_data)"><pre class="notranslate"><code class="notranslate">json_data = [ ... ];
r = requests.Request('POST', url, json=json_data)
</code></pre></div>
<p dir="auto">And in the <code class="notranslate">2.8.0</code> version this code does not work, because I do not specify <code class="notranslate">data</code> parameter. Inside constructor we get <code class="notranslate">self.data</code> assigned as <code class="notranslate">[] if data is None else data</code>, so we finally get <code class="notranslate">self.data</code> equal to <code class="notranslate">[]</code>.</p>
<p dir="auto">And because of this commit: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/psf/requests/commit/7a0cd16c1a5be16f3df395ee12ed11d0ddde7837/hovercard" href="https://github.com/psf/requests/commit/7a0cd16c1a5be16f3df395ee12ed11d0ddde7837"><tt>7a0cd16</tt></a> we get <code class="notranslate">json</code> parameter ignored, because now we have to explicitly specify <code class="notranslate">data={}</code> when calling constructor, like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="json_data = [ ... ];
r = requests.Request('POST', url, json=json_data, data={})"><pre class="notranslate"><code class="notranslate">json_data = [ ... ];
r = requests.Request('POST', url, json=json_data, data={})
</code></pre></div>
<p dir="auto">I think that this issue definitely breaks documented API.</p>