2

I'm doing a post request using python and confluence REST API in order to update confluence pages via a script. I ran into a problem which caused me to receive a 400 error in response to a requests.put(url, data = jsonData, auth = (username, passwd), headers = {'Content-Type' : 'application/json'})

I spent some time on this to discover that the reason for it was me not supplying an incremented version when updating the content. I have managed to make my script work, but that is not the point of this question.

During my attempts to make this work, I swapped from requests to an http.client connection. Using this module, I get a lot more information regarding my error:

b'{"statusCode":400,"data":{"authorized":false,"valid":true,"allowedInReadOnlyMode":true,"errors":[],"successful":false},"message":"Must supply an incremented version when updating Content. No version supplied.","reason":"Bad Request"}'

Is there a way for me to get the same feedback information while using requests? I've turned on logging, but this kind of info is never shown.

3
  • 1
    What does requests.json() output? Commented Apr 17, 2019 at 9:25
  • Exactly what I needed :) I tried several options but was not aware of this one. Thank you! Commented Apr 17, 2019 at 9:30
  • To get more logs from the requests module assign the request output to a var and print the .text attribute, e.g. var = requests.put(url, data = jsonData, auth = (username, passwd), headers = {'Content-Type' : 'application/json'}) \\ print(var.text) Commented Feb 19, 2024 at 13:46

1 Answer 1

6

You're looking for

requests.json()

It outputs everything the requests item returns, as a dictionary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.