Set version for page via API

Comments

4 comments

  • Official comment
    Avatar
    K15t Team

    Hi Pavel,

    the default character set used in the REST requests is UTF-8. Thus %20 is resolved to space. (We will check if there is a bug).

    So using Cyrillic in the request will not work. I used https://www.w3schools.com/tags/ref_urlencode.asp > URL Encoding Functions to check how Текст is encoded in a URL.

    Текст has a URL representation of %D0%A2%D0%B5%D0%BA%D1%81%D1%82

    How do you trigger that call? If it is used from the UI or any other piece of code you should be able to URL encode your text using corresponding libs.

    Does this answer your question?

    Best,
    Tobias

  • Avatar
    Pavel (Edited )

    Hi Tobias,

    I test call via curl

    curl.exe -u "user:password" --insecure https://wiki/rest/scroll-versions/1.0/page/modify/ASRU -d "masterPageId=202394582&pageTitle=%D0%A2%D0%B5%D0%BA%D1%81%D1%82&versionId=0A6573030164D1D88A766A147ED450F1&changeType=Modify" -X POST -H "X-Atlassian-Token:nocheck" -H "Content-Type:application/x-www-form-urlencoded" --output Response.txt --trace-ascii trace.txt

    I know about encoder/decoder, but with pageTitle=%D0%A2%D0%B5%D0%BA%D1%81%D1%82 page will have title A2B5BA8182. It is not correct

  • Avatar
    Roman Serazhiev

    Hi Pavel.

    The request with the encoded word Текст works without problems for me. Here is a screenshot of the request and the result:



    Please check if there could be some differences between my request and yours.

    Cheers,
    Roman.

  • Avatar
    Pavel (Edited )

    Hi Roman!

    I reproduced the request with the correct parameters and Cyrillic title.

     In pyton (pageTitle  can consist of Cyrillic alphabet):
    ...
    pageTitle=pageTitle.encode('utf-8')
    params = {"masterPageId": masterPageId, "pageTitle": pageTitle, "versionId": versionId,
              "changeType": "Modify"}
    url_params = urllib.urlencode(params)
    url_post = self.uri_base + '/rest/scroll-versions/1.0/page/modify/' + self.space + '?' + url_params
    data = ''
    headers = {'X-Atlassian-Token': 'nocheck', 'Content-Type': 'application/x-www-form-urlencoded'}
    response = requests.post(url_post, data=data, headers=headers,
    auth=(self.username, self.password), verify=False)

    Thanks!

Please sign in to leave a comment.

Powered by Zendesk