0

OK, so I know how to upload to SharePoint thanks to this question:

How to send file to Sharepoint from Linux creating non existend directories

Now I am trying to figure out how to do it with Atlassian's Confluence. Any takers?

What I am looking for is a scriptable Unix command.

2
  • So looking at some Confluence pages, I see *.action pages which usually indicates a Struts implementation. In theory, all I need to do is figure out what action to call with what parameters. Commented Nov 4, 2013 at 17:48
  • What about the possibility of using lynx + an expect script to do the upload? Commented Nov 4, 2013 at 18:31

3 Answers 3

2

You question needs improving for a real understanding of what you're trying to achieve. That said, you can for example attach a file to a page within Confluence using curl.

The easy way to use do this would be using Bob Swifts Atlassian/Confluence CLI using the addAttachment command to add an attachment.

The plugin changed to be commercial a while back, but you can download the latest free release here.

Sign up to request clarification or add additional context in comments.

1 Comment

Agreed. An attachment is acceptable but not optimal. What I was thinking was that I could use web tools to look at the headers and actions processed when a page is edited. See where the text is and then devise a script command that simulates. Unfortunately, I can't do any of this now that my project has tanked and I'm on the lookout for a new gig. :-/ That's the tech industry for ya. Easy come, easy go.
0

You can do it by running the below command from UNIX.

curl -u $USER_NAME:$USER_PASSWORD  -X POST -H "X-Atlassian-Token: nocheck" -F "file=@${ATTACHMENT_FILE_NAME}" -F "comment=File attached via REST API" ${CONFLUENCE_BASE_URL}/rest/api/content/${PAGE_ID}/child/attachment 2>/dev/null

More information in this link: https://confluence.atlassian.com/confkb/using-the-confluence-rest-api-to-upload-an-attachment-to-one-or-more-pages-1014274390.html

Comments

-1

Here is the correct syntax:

curl -X POST \
   -u "$USER_EMAIL:$ATLASSIAN_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
        "spaceId": "12345",
        "title": "Hello World",
        "status": "draft",
        "body": {
            "representation": "storage",
            "value": "<p>Page created from cURL</p>"
        }
    }' \
    "https://$ATLASSIAN_INSTANCE/wiki/api/v2/pages"

Just replace the "12345" with the space id you want to target (beware: you can't use $VARIABLE there, due to sigle quote). To learn more on how to find the other variables, read my blog: https://ducttapecode.com/blog/confluence-integration/article/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.