Hi,
I need to export a single page to PDF from a script. As far as I understand, the options are:
I would like to use option 3. According to the docs I can use either Basic authentication, which means hardcoding user credentials in a script, or OAuth, which requires a token. I would be happier about OAuth, but from the admin panel it looks like I can generate tokens only for apps/plugins; therefore I must use some user credentials in the scripts, which looks unsafe and cumbersome.
Is there any other way to export a PDF without additional plugins and without using user credentials? Is there any way to generate a token for a script?
Thank you.
In case someone else is interested: yes, it is possible. The "app URL" can be an arbitrary "virtual" URL and the authentication process can be triggered by command line (the sample clients will provide a link to authenticate a token via browser once).
How did you get it to work?
I can get the Chrome to visit https://domain_name/rest/api/content/38699012
When I run curl:
curl -u user_id:password "https://domain_name/spaces/flyingpdf/pdfexport.action?pageId=38699012"
I get a Page Not Found HTML document.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
it should work with the same link used in the browser (e.g. inspecting "download to PDF" item). In my case:
"https://domain/confluence/spaces/flyingpdf/pdfpageexport.action?pageId=$pageId"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure why but Postman handles those sorts of URLs while curl didn't. I also tried Postman's feature that exports the code to run it in curl.
I found that solution #2 of https://stackoverflow.com/questions/38770934/how-to-export-to-pdf-a-confluence-page-within-a-script worked.
(Our domain is on Confluence 5.10.2 and had the XML-RPC and SOAP APIs enabled as in solution #1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The "page not found" is probably a mistake in the URL. With the correct URL, curl should output the HTTP response headers, which include the Location. Maybe postman automatically parses the Location and redirects the request to it? That should be the PDF URL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not that since the URL is okay with Postman then the curl command exported from Postman doesn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.