create page "POST /wiki/rest/api/content/ HTTP/1.1" 415

Sukhjinder Bhullar January 22, 2020

Hi, 

I am trying to create page using python requests module and getting 415. 

here is my python function : 

def create_page(contenturlheaders):
    create_page = {        "type""page",        "title""test",        "space": {"key": space_key},        "ancestors": [{"id": parent_page_id}],        "status""current",        "body": {            "storage": {"value""This is a new page""representation""storage",}        },    }
    response = requests.post(contenturl, data=create_page, headers=headers)    print(response.status_code)

 

here are my headers: 

headers = {    "accept": "application/json",    "authorization": "Basic %s" % encoded,}

 

I do not see authorization is issue here because that i am able to make get content and delete page calls. I have tried adding "X-Atlassian-Token": "no-check" but still gets 415. My user also has full access to write and read.

 

any  help appreciated. 

 

Regards

Sukh

 

1 answer

1 vote
Sukhjinder Bhullar January 22, 2020

There was an issue with body. It got resolved after providing body in html format. 

 

 "body": {            "storage": {"value""This is a new page""representation""storage",}        },    }

 

to 

 

"body": {            "storage": {"value": "<p>This is a new page</p>", "representation": "storage",}        },    }

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events