Code Monkey home page Code Monkey logo

Comments (2)

gkowalc avatar gkowalc commented on July 4, 2024

Do you want to get storage format of each returned page returned by cql? If so this won' work with this single api call:

test = confleunce_cloud.cql(cql='space = "TEST"', limit=25, expand='content.body.storage')
json = json.dumps(test, indent=4)
print(json)

you will get something like:

    "results": [
        {
            "content": {
                "id": "448972356",
                "type": "page",
                "status": "current",
                "title": "test",
                "macroRenderedOutput": {},
                "body": {
                    "storage": {
                        "value": "test",
                        "representation": "storage",
                        "embeddedContent": [],
                        "_expandable": {
                            "content": "/rest/api/content/448972356"
                        }
                    },
                    "_expandable": {
                        "editor": "",
                        "atlas_doc_format": "",
                        "view": "",
                        "export_view": "",
                        "styled_view": "",
                        "dynamic": "",
                        "editor2": "",
                        "anonymous_export_view": ""
                    }

As you can see body.storage. doesn't include any valuable information returned by the API.

However, you can try doing something like this instead:

import json
test = confleunce_cloud.cql(cql=' type=page AND title  ~ "test"', limit=25)
for issue in test['results']:
       page_storage_form =  confleunce_cloud.get_page_by_id(issue['content']['id'], expand='body.storage')
       print(page_storage_form['body']['storage']['value'])

this will return all the storage formats from pages returned by cql. Let me know if this works.

from atlassian-python-api.

ZlobinaElena avatar ZlobinaElena commented on July 4, 2024

Thank you for your response. I have encountered a challenge while attempting to retrieve all pages using the start and limit parameters. Unfortunately, the current implementation does not seem to be working as expected, as I keep receiving the same pages in each iteration. It appears that the start parameter is not functioning correctly.
Code Snippet:

res = []
start = 0
limit = 5

while True:
    test = confluence.cql(cql='space = "TEST" and type = page', start=start, limit=limit, expand='content.body.storage')
    test = test.get("results", [])
    res.extend(test)
    if len(test) < 5:
        break
    start += limit

print(len(res))

Could you please help me identify the issue and provide guidance on how to correctly use the start parameter to fetch all pages? Your assistance is greatly appreciated.

from atlassian-python-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.