Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

CURL | Upload multiple html files to confluence

Kalyan December 19, 2018

I need to upload html files from Jenkins workspace to confluence via CURL command.

Script used:-


curl -v -S -u $USERNAME:$PASSWORD -X POST -H "X-Atlassian-Token: no-check" -F "file_0=@code/pydoc/manage_connections.html" "https://alm-group.atlassian.net/wiki/spaces/PROJECT/pages/830833705/PyDoc"

Issue is- It is uploading single file as a attachment. I need to upload bunch of files but I am not able to do it.

I followed below link but unable to crack it.
https://developer.atlassian.com/cloud/confluence/rest/#api-content-get

1 answer

0 votes
Thomas Deiler
Community Champion
December 20, 2018

Dear @Kalyan,

you have to create a MultiPartEntity request. Follow this https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-child-attachment-post

Have also a look at https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/#content/{id}/child/attachment-createAttachments

This is Confluence Server but its similar.

So long

Thomas

Kalyan December 21, 2018

Hi @Thomas Deiler,

 

Thank you for the response. But Could you provide me an example for the same. I feel I used same command to push .html file as a attachment to confluence.

I need to send multiple html files at a time.

Thomas Deiler
Community Champion
January 15, 2019

Have a look at this snippet:

import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.Header;

HttpPost postRequest = new HttpPost(url);
postRequest.addHeader(/* has to be ""X-Atlassian-Token", "nocheck"" */);
MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create();
multipartEntity.setMode(HttpMultipartMode.STRICT);
multipartEntity.addBinaryBody("file", new File(path_1));
multipartEntity.addBinaryBody("file", new File(path_2));
postRequest.setEntity(multipartEntity.build());

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events