Python PUT Request to Confluence Webpage - ValueError: No JSON object could be decoded, but <Response [200]>
<p>I'm trying to update some data on a confluence webpage. Everything works fine in Postman (the data is updated). However, when I use python and the requests module I'm getting the following error:</p>

<blockquote>
  <p>ValueError: No JSON object could be decoded</p>
</blockquote>

<p>The strangest thing is I'm getting a 200 status code back but the webpage isn't updating. The error seems to root from typing 'r.json'.</p>

<p>Here is my code (I'm trying to change the content of the webpage to 'Hello World'):</p>

<pre><code>import requests
import json

url = &lt;url&gt;

data = {
    "id": "18219205",
    "title": "Testapi",
    "type": "page",
    "version": {
        "number": 11
    },
    "body": {
        "storage": {
            "representation": "storage",
            "value": "Hello world."
        }
    }
}
dumped_data = json.dumps(data)

headers = {
    'content-type': "application/json",
    'authorization': "Basic &lt;token number&gt;",
    'cache-control': "no-cache",
    'postman-token': "&lt;another token&gt;"
    }

r = requests.put(url, data=dumped_data, headers=headers, verify=False)

print r.json()
</code></pre>

<p>This is happening because the API you're posting to doesn't respond with JSON, so when you call <code>r.json()</code> requests tries to parse the body of the response as JSON and fails. You're seeing a 200 because you were able to send the data to the server correctly, you're just trying to read the response wrong.</p>

<p>From the <a href="http://docs.python-requests.org/en/master/user/quickstart/" rel="nofollow">Requests docs</a>:</p>

<blockquote>
  <p>For example, if the response gets a 204 (No Content), or if the response contains invalid JSON, attempting r.json() raises ValueError: No JSON object could be decoded.</p>
</blockquote>

python python-requests put confluence