G
G
god_dan632021-11-16 12:12:07
Python
god_dan63, 2021-11-16 12:12:07

How to change page in confluence using Python?

Good afternoon!
I can't figure out how to change the page in the confluence api.

I can get the page code itself using the get method:

def get_page_info(Link, login, password):
    #Берем "Суп" страницы:
    r = requests.get(str(Link), auth=HTTPBasicAuth(str(login), str(password)),verify=False)
    return r


I'm trying to run everything and use the put method to change the content:
def write_data():
    headers = {
        'Content-Type': 'application',
    }
    info = get_page_info('https://confluence........ru/pages/viewpage.action?pageId=635355', "111111","9999999")
    date = {"version": {"number": 2},
            "title": "КБ_9999 - Global Site",
            "type": "page",
            "body": {"storage": {"value": "<p>TESTTT.</p>",
            "representation": "storage"}}}
    response = requests.put('https://confluence.........ru/pages/viewpage.action?pageId=613355',headers=headers ,data=json.dumps(date), auth=HTTPBasicAuth(".....", '.....'),verify=False)
    result = get_page_info('https://confluence........ru/pages/viewpage.action?pageId=613655', "99999,"99999")
    print('1',result)
    

    
write_data()

(logins and passwords indicated random for the question)

I get a constant Response [200], but no changes happen to the page!
Perhaps I did not specify the values ​​​​in the date dictionary correctly?
Can you please explain why headers are needed and where do I get the values ​​for the date dictionary?
I took this code as an example from the Internet, I did not fully understand how it works

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question