Closed GMous closed 10 months ago
Can you elaborate on what Confluence is returning? HTTP 200 OK
is an expected HTTP status code. Is there no response body? If there is a body, what does it contain? (From the error message, it looks like it's not JSON.)
I'm not very familiar with python and confluence API, but I've just inserted "print(response)" in api.py before line 188 and I got string "<Response [200]>".
When you do a print(response)
, Python would print the string representation of the object held in the variable response
as defined by the object type. Developers of the Requests library have likely opted to do a compact representation that prints the status code, and nothing else. What would be interesting to know is what the actual response payload is. Normally, this should be a JSON string, which is de-serialized automatically into a Python object when calling response.json()
. Since the function call to response.json()
is triggering an error, you would need to call print
on response.text
, which could produce the response body as-is, revealing what Confluence is returning.
Thanks for info. I've checked it and found that response.text contains HTML, indicating that my user doesn't have access to the page. However, this page is in my own user space and doesn't have any restrictions. Additionally, I've tried creating a simple custom script using the atlassian-python-api module, and it works with the same initial data (token, space key, page id).
Looking at the implementation of the class AtlassianRestAPI
in the library atlassian-python-api, it looks way more complex than the basic authentication scheme available in md2conf. I would need to understand which exact authentication path is taken in AtlassianRestAPI
such that it could be reproduced in the corresponding API wrapper in md2conf. For example, I could include requests-oauthlib in md2conf but we would need to identify first if this is indeed what is lacking in your case.
I've used authentication with a personal access token in the following way:
confluence = Confluence(url=confluence_url, token=api_token)
It seems that it simply adds an "Authorization" header with the value "Bearer {token}".format(token=token)
.
If you don't pass a user name, md2conf will also call
session.headers.update({"Authorization": f"Bearer {self.api_key}"})
Perhaps you have a stray setting that assigns the environment variable CONFLUENCE_USER_NAME
and thus invokes the HTTP basic authentication path in md2conf as opposed to the desired HTTP bearer authentication path (as in AtlassianRestAPI
).
I was digging deep into debugging when I realised that I had missed the default value of the wiki PATH parameter. I feel so silly. Really sorry for your time. I've just added -p /
to parameters and it works now.
That's great news! Don't worry; the important point is that you got it working in the end.
Confluence version: 8.2.3 Server Edition markdown-to-confluence installed with pip, version: 0.1.10
Confluence returns: "<Response [200]>"
Exception message: