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
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.