Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Confluence]: Method to obtain page content #180

Closed
argysamo opened this issue Apr 16, 2019 · 9 comments
Closed

[Confluence]: Method to obtain page content #180

argysamo opened this issue Apr 16, 2019 · 9 comments

Comments

@argysamo
Copy link

It would be nice to have a method to obtain the body of a given page.
You could then update a page, making modifications to its body.
This method will have as an input the page_id and return the page body content formatted as html.
I will soon submit a PR to fix this issue.

(If I am not mistaken, the current update_or_create() method replaces the content of the page.)

Kind regards,
Argyris

@gonchik
Copy link
Member

gonchik commented May 21, 2019

Hi!
I hope that commit will cover your request
1b875e8

Cheers,
Gonchik Tsymzhitov

@kierun
Copy link

kierun commented Jun 4, 2019

1b875e8 seems to be about appending to a page. As far as I understand @argysamo request, this is about getting the whole content of a page.

As simple use case would be:

  • Get the page's data.
  • Find some field within said data -- for example a page property.
  • Update said field to a new value.
  • Upload the new page content.

Or is that already possible and I somehow missed it?

@gonchik
Copy link
Member

gonchik commented Jun 4, 2019

@kierun Well, you can do in different ways i.e.
old_content = confluence.get_page_by_id(123).expand='storage.view' body = (((result.get('body') or {}).get('view') or {}).get('value') or {}) body.replace("oldvalue", "new_value") confluence.updade_page(old_content.get('id'), body=body)

https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/confluence.py#L505
https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/confluence.py#L541

@gonchik gonchik closed this as completed Jun 18, 2019
@freeyland
Copy link

@gonchik When trying previous i am getting:
AttributeError: 'dict' object has no attribute 'expand'

@freeyland
Copy link

freeyland commented Aug 7, 2019

SHould be I think:
confluence.get_page_by_id(page_id, expand='storage.view')
But : 'bool' object has no attribute 'get'

@gonchik
Copy link
Member

gonchik commented Aug 7, 2019

@freeyland on which did you try it?

@freeyland
Copy link

It is working, made a mistake in my code. Thnx for quick reply

@freeyland
Copy link

freeyland commented Aug 7, 2019

@gonchik When Updating Im getting:
{'statusCode': 400, 'message': 'org.codehaus.jackson.map.JsonMappingException: Instantiation of [simple type, class com.atlassian.confluence.api.model.content.id.ContentId] value failed: Can't parse as a ContentId:

Hallo

(through reference chain: com.atlassian.confluence.api.model.content.Content["ancestors"]->com.atlassian.confluence.api.model.content.Content["id"])'}
body.replace("Hallo", "Hallo2") result = confluence.update_page( parentID, pageID, 'Versions & Changelogs', body, 'page', 'wiki')

@gonchik
Copy link
Member

gonchik commented Aug 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants