Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to upload a file using existing confluenceLink

Hi im trying to figure out how to upload an existing File to Confluence using the primary confluenceLink

This is my actual code (groovy):


import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import org.apache.http.entity.FileEntity

def logger = Logger.getLogger("com.nolddor")

ApplicationLinkService applicationLinkService

// You must change the following variables as per your needs
def pageId = "6060557" 														// Confluence page
def documentPath = "/var/atlassian/application-data/jirasd/dbconfig.xml" 	// Attachment path

// Ensure the existence of a working Confluence application link
def confluenceLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class)
assert confluenceLink : "Unable to retrieve primary Confluence application link."

// Grab the attachment from the filesystem
def file = new File(documentPath)

// REST Call
	.createRequest(Request.MethodType.POST, "rest/api/content/${pageId}/child/attachment")
    .addHeader("X-Atlassian-Token", "no-check")
    .addHeader("Content-Type", "multipart/form-data")
	.addHeader("Accept", "application/json")
    .setEntity(new FileEntity(file))
    .execute(new ResponseHandler<Response>() {
        void handle(Response response) throws ResponseException {
            def responseBodyAsString = response.getResponseBodyAsString();
            if(!response.successful) {
                throw new Exception("Unable to attach file to Conflunce page (id=${pageId}).\n Http-Response: ${responseBodyAsString}");


However it seems the already created authenticatedRequest is not able to handle a FileEntity because some misconfiguration on Jersey client. Any help?

java.lang.RuntimeException: Unable to find a message body writer for class org.apache.http.entity.FileEntity
	at com.atlassian.applinks.core.auth.ApplicationLinkRequestAdaptor.execute(
	at com.atlassian.applinks.oauth.auth.OAuthRequest.execute(
	at$execute$ Source)








1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you