I'm trying to use Confluence Automation Rules to upload an attachment (a PDF export of a page, generated by a Web Request to a third-party API).
My Automation Rule successfully generates the page export and I receive a download URL for the PDF. I'm trying to send a web request to the Confluence REST API to upload the PDF as an attachment to a Confluence page, using the Create Attachment endpoint. and a Send Web Request action.
It's not clear what is the proper way to format this request when attaching a file via a URL. I assume it is possible to do so since the standard user interface permits this. The curl examples all upload a binary file from the local filesystem, which is useless for an Automation Rule.
My Confluence token has write:confluence-file, write:attachment:confluence, and read:content-details:confluence scopes (and nothing else).
The API request is configured as follows:
I always receive the response HTTP 415 Unsupported Media Type.
If I migrate Content-Type: multipart/form-data; boundary=... to the Headers then I instead get HTTP 403 Forbidden.
I've also tried retrieving the file using another Web Request and storing the result into a variable, then retrieving that smart value in the body of the request as follows (with and without .urlEncode), unsuccesfully - I have tried with Content-Disposition: application/pdf and application/octet-stream, also without any content type specifier.
Is it possible to attach a file to a page from a web URL? How should I modify the request to do so?
If not, is there some way I can retrieve the binary blob from my file download URL, and encode it in the request as application/pdf or application/octet-stream?
edit:
I tried Authorization: Basic {{encodedCredentials}}, instead of Bearer Authorization and still get 403 "Current user not permitted to use Confluence", where credentials are encoded offline using echo "<email>:<PAT>" | base64.
I've also seen claims online that base64Encode is a function that exists and can be used per below however that didn't work at all (nested braces don't seem to be supported).
{{base64Encode("{{initiator.emailAddress}}:{{confluencePAT}}")}}