justmiles / go-markdown2confluence

Push markdown files to Confluence Cloud
Mozilla Public License 2.0
254 stars 48 forks source link

local images not uploaded to Confluence attachments (and thus not rendering) #72

Open cthenb opened 9 months ago

cthenb commented 9 months ago

OS: Win11 Version used: latest (3.4.6) Confluence type: datacenter Use case: want to upload plantuml files that have already been converted to .png by the plantuml tool to confluence alongside other documentation.

Problem description:

point of reference; https://github.com/justmiles/go-markdown2confluence/issues/10

Authentication: access token

Simplified file structure: D:\markdown2confluence (added to path)

In C:\Users\\: Documentation \ <Parent page name> \ document.md Documentation \ <Parent page name> \ <Subparent page name> \ document2.md drawings \ drawing.puml images \ drawing.png plantuml.jar

Content of document.md (converted to above simplification):


DPL - Diagram

Let op: Deze pagina is gemaakt in bitbucket met markdown. Om deze in Confluence te updaten:

markdown2confluence --space 'X' --parent 'DPL - Algemeen' --use-document-title

![Diagram.png](../../images/drawing.png)


I've also tried /images/drawing.png to specify the root of the project, but that won't render the image locally.

Command 1: PS <project directory>\Documentation\DPL - Algemeen> markdown2confluence sync --space 'X' --parent 'DPL - Algemeen' --use-document-title --debug '.\' Output: --space is not defined

The above is what's listed on the homepage documentation. Very weird that it won't work if you include 'sync'

Command 2: `PS \Documentation\DPL - Algemeen> markdown2confluence --space 'DIT' --parent 'DPL - Algemeen' --use-document-title --debug '.\' sync

Output: Error opening file open sync: The system cannot find the file specified.

Command 3 (this one works in that it creates the pages, just not the images): markdown2confluence --space 'DIT' --parent 'DPL - Algemeen' --use-document-title --debug '.\' Output: `Searching for parent DPL - Algemeen time="2024-01-19T10:51:48+01:00" level=debug msg="GET https://redacted.nl/rest/api/content?limit=1&spaceKey=X&title=DPL+-+Algemeen&type=page" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Status Code: 200" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Body: '{\"results\":[{\"id\":\"366711776\",\"type\":\"page\",\"status\":\"current\",\"title\":\"DPL - Algemeen\",\"extensions\":{\"position\":0},\"_links\":{\"webui\":\"/display/X/DPL+-+Algemeen\",\"eX\":\"/pages/resumedraft.action?draftId=36671 1776\",\"tinyui\":\"/x/4JPbFQ\",\"self\":\"https://redacted.nl/rest/api/content/366711776\"},\"_expandable\":{\"container\":\"/rest/api/space/X\",\"metadata\":\"\",\"operations\":\"\",\"children\":\"/rest/api/content/366711776/child\",\"restrictions\":\"/rest/api/content/366711776/restriction/ byOperation\",\"history\":\"/rest/api/content/366711776/history\",\"ancestors\":\"\",\"body\":\"\",\"version\":\"\",\"descendants\":\"/rest/api/content/366711776/descendant\",\"space\":\"/rest/api/space/X\"}}],\"start\":0,\"limit\":1,\"size\":1,\"_links\":{\"self\":\"https://redacted.nl/rest/api/content?spaceKey=X&title=DPL+-+Algemeen&type=page\",\"base\":\"https://redacted.nl\",\"context\":\"\"}}'" DPL - Diagram van redacted Componenten.md DPL - Diagram van netwerken en omgevingen.md DPL - Diagram van infrastructuur team redacted.md ---- RENDERED CONTENT START ---------------------------------

DPL - Diagram van redacted Componenten

Let op: Deze pagina is gemaakt in bitbucket met markdown. Om deze in Confluence te updaten:

markdown2confluence --space 'X' --parent 'DPL - Algemeen' --use-document-title

![Diagram.png](../../images/redacted Componenten.png)

---- RENDERED CONTENT END ----------------------------------- time="2024-01-19T10:51:48+01:00" level=debug msg="GET https://redacted.nl/rest/api/content?expand=version%2Cbody.storage&limit=1&spaceKey=X&title=DPL+-+Diagram+van+redacted+Componenten%0D&type=page" ---- RENDERED CONTENT START ---------------------------------

DPL - Diagram van netwerken en omgevingen

Let op: Deze pagina is gemaakt in bitbucket met markdown. Om deze in Confluence te updaten:

markdown2confluence --space 'X' --parent 'DPL - Algemeen' --use-document-title

![Diagram](../../images/Netwerken en omgevingen.png)

---- RENDERED CONTENT END ----------------------------------- ---- RENDERED CONTENT START --------------------------------- time="2024-01-19T10:51:48+01:00" level=debug msg="GET https://redacted.nl/rest/api/content?expand=version%2Cbody.storage&limit=1&spaceKey=X&title=DPL+-+Diagram+van+netwerken+en+omgevingen%0D&type=page"

DPL - Diagram van infrastructuur team redacted

Let op: Deze pagina is gemaakt in bitbucket met markdown. Om deze in Confluence te updaten:

markdown2confluence --space 'X' --parent 'DPL - Algemeen' --use-document-title

![Diagram](../../images/Infrastructuur team redacted.png)

---- RENDERED CONTENT END ----------------------------------- DPL - Diagram van gebruikte configuratie redacted.md time="2024-01-19T10:51:48+01:00" level=debug msg="GET https://redacted.nl/rest/api/content?expand=version%2Cbody.storage&limit=1&spaceKey=X&title=DPL+-+Diagram+van+infrastructuur+team+redacted%0D&type=page" ---- RENDERED CONTENT START ---------------------------------

DPL - Diagram van gebruikte configuratie redacted

Let op: Deze pagina is gemaakt in bitbucket met markdown. Om deze in Confluence te updaten:

markdown2confluence --space 'X' --parent 'DPL - Algemeen' --use-document-title

![Diagram](../../images/Gebruikte configuratie redacted.png)

---- RENDERED CONTENT END ----------------------------------- time="2024-01-19T10:51:48+01:00" level=debug msg="GET https://redacted.nl/rest/api/content?expand=version%2Cbody.storage&limit=1&spaceKey=X&title=DPL+-+Diagram+van+gebruikte+configuratie+redacted%0D&type=page" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Status Code: 200" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Body: '{\"results\":[],\"start\":0,\"limit\":1,\"size\":0,\"_links\":{\"self\":\"https://redacted.nl/rest/api/content?spaceKey=X&expand=version%2Cbody.storage&title=DPL+-+Diagram+van+redacted+Componenten%0D&type=page\",\"base\":\"https://redacted.nl\",\"context\":\"\"}}'" time="2024-01-19T10:51:48+01:00" level=debug msg="POST https://redacted.nl/rest/api/content" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Status Code: 200" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Body: '{\"results\":[],\"start\":0,\"limit\":1,\"size\":0,\"_links\":{\"self\":\"https://redacted.nl/rest/api/content?spaceKey=X&expand=version%2Cbody.storage&title=DPL+-+Diagram+van+netwerken+en+omgevingen%0D&type=page\",\"base\":\"https://redacted.nl\",\"context\":\"\"}}'" time="2024-01-19T10:51:48+01:00" level=debug msg="POST https://redacted.nl/rest/api/content" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Status Code: 200" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Body: '{\"results\":[],\"start\":0,\"limit\":1,\"size\":0,\"_links\":{\"self\":\"https://redacted.nl/rest/api/content?spaceKey=X&expand=version%2Cbody.storage&title=DPL+-+Diagram+van+infrastructuur+team+redacted%0D&type=page\",\"base\":\"https://redacted.nl\",\"context\":\"\"}}'" time="2024-01-19T10:51:48+01:00" level=debug msg="POST https://redacted.nl/rest/api/content" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Status Code: 200" time="2024-01-19T10:51:48+01:00" level=debug msg="Response Body: '{\"results\":[],\"start\":0,\"limit\":1,\"size\":0,\"_links\":{\"self\":\"https://redacted.nl/rest/api/content?spaceKey=X&expand=version%2Cbody.storage&title=DPL+-+Diagram+van+gebruikte+configuratie+redacted%0D&type=page\",\"base\":\"https://redacted.nl\",\"context\":\"\"}}'" time="2024-01-19T10:51:48+01:00" level=debug msg="POST https://redacted.nl/rest/api/content" time="2024-01-19T10:51:49+01:00" level=debug msg="Response Status Code: 400" time="2024-01-19T10:51:49+01:00" level=debug msg="Response Body: '{\"statusCode\":400,\"data\":{\"authorized\":false,\"valid\":true,\"allowedInReadOnlyMode\":true,\"errors\":[],\"successful\":false},\"message\":\"A page with this title already exists: A page already exists with the title DPL - Diagram van infrastructuur team redacted in the space with key X\",\"reason\":\"Bad Request\"}'" time="2024-01-19T10:51:49+01:00" level=error msg="A page with this title already exists: A page already exists with the title DPL - Diagram van infrastructuur team redacted in the space with key X" time="2024-01-19T10:51:49+01:00" level=debug msg="Response Status Code: 400" : L - Algemeen/DPL - Diagram van infrastructuur team redacted time="2024-01-19T10:51:49+01:00" level=debug msg="Response Status Code: 400" time="2024-01-19T10:51:49+01:00" level=debug msg="Response Body: '{\"statusCode\":400,\"data\":{\"authorized\":false,\"valid\":true,\"allowedInReadOnlyMode\":true,\"errors\":[],\"successful\":false},\"message\":\"A page with this title already exists: A page already exists with the title DPL - Diagram van netwerken en omgevingen in the space with key X\",\"reason\":\"Bad Request\"}'" time="2024-01-19T10:51:49+01:00" level=error msg="A page with this title already exists: A page already exists with the title DPL - Diagram van netwerken en omgevingen in the space with key X" : L - Algemeen/DPL - Diagram van netwerken en omgevingen time="2024-01-19T10:51:49+01:00" level=debug msg="Response Body: '{\"statusCode\":400,\"data\":{\"authorized\":false,\"valid\":true,\"allowedInReadOnlyMode\":true,\"errors\":[],\"successful\":false},\"message\":\"A page with this title already exists: A page already exists with the title DPL - Diagram van redacted Componenten in the space with key X\",\"reason\":\"Bad Request\"}'" time="2024-01-19T10:51:49+01:00" level=error msg="A page with this title already exists: A page already exists with the title DPL - Diagram van redacted Componenten in the space with key X" : L - Algemeen/DPL - Diagram van redacted Componenten time="2024-01-19T10:51:49+01:00" level=debug msg="Response Status Code: 400" time="2024-01-19T10:51:49+01:00" level=debug msg="Response Body: '{\"statusCode\":400,\"data\":{\"authorized\":false,\"valid\":true,\"allowedInReadOnlyMode\":true,\"errors\":[],\"successful\":false},\"message\":\"A page with this title already exists: A page already exists with the title DPL - Diagram van gebruikte configuratie redacted in the space with key X\",\"reason\":\"Bad Request\"}'" time="2024-01-19T10:51:49+01:00" level=error msg="A page with this title already exists: A page already exists with the title DPL - Diagram van gebruikte configuratie redacted in the space with key X" : L - Algemeen/DPL - Diagram van gebruikte configuratie redacted Unable to upload markdown file DPL - Diagram van netwerken en omgevingen.md: Error creating page: A page with this title already exists: A page already exists with the title DPL - Diagram van netwerken en omgevingen in the space with key X

Unable to upload markdown file DPL - Diagram van redacted Componenten.md: Error creating page: A page with this title already exists: A page already exists with the title DPL - Diagram van redacted Componenten in the space with key X

Unable to upload markdown file DPL - Diagram van gebruikte configuratie redacted.md: Error creating page: A page with this title already exists: A page already exists with the title DPL - Diagram van gebruikte configuratie redacted in the space with key X`

justmiles commented 9 months ago

Apologies on the disconnect between the documentation and what you're seeing. I'm actually re-factoring a bit right now and the documentation on master is showing the latest changes, not the latest stable release.

You can reference the documentation for the latest stable release here.

I believe I addressed these image issues in the latest alpha release. Would you mind trying that?

justmiles commented 9 months ago

I just realized you're shipping to the datacenter confluence instance. The API is different for the datacenter and I don't have an instance of it to test against. I wouldn't expect the alpha release to work against a datacenter instance at this time.

cthenb commented 9 months ago

I'll try the alpha nonetheless, you never know 🙂

If it doesn't work, I'd be open for doing a debug session if you are.

cthenb commented 9 months ago

@justmiles you were right. Using the sync command of the alpha version on a page with a picture and one without a picture results in the same error below

I get: level=error msg="Unable to unmarshal response. Received: ' \n\n<!DOCTYPE html>\n<html lang=\"en-GB\" >\n<head>\n <title>You are already logged in - TOPAAS Confluence</title>\n .... invalid character '<' looking for beginning of value

I've also learned my company will be migrating to Confluence Cloud in 2 months, so on my end I'd be comfortable waiting the migration out. If you'd like to get this working on datacenter, I'd still be open to do a shared debug session, though!