The Request Javascript module provides a mechanism for an add-on rendered in an iframe to make an XMLHttpRequest to the host product without requiring CORS.

In contrast to REST calls made from the add-on server to the product directly, any requests made in the browser are evaluated in the context of the currently logged in user. The requested resource is still evaluated against the add-ons granted scopes.


AP.request('../assets/js/rest-example.json', {
  success: function(responseText){


request(url, options)

Execute an XMLHttpRequest in the context of the host application. The format of the response (dataType) will always be set to "text" - even if specified.

Name Type Description
url String

Either the URI to request or an options object (as below) containing at least a 'url' property;
This value should be relative to the context path of the host application.

options Object

The options of the request.

Name Type Default Required Description
url String Required

The url to request from the host application, relative to the host's context path

type String GET

The HTTP method name.

cache Boolean true

If the request should be cached.

data String | Object

The body of the request; required if type is 'POST' or 'PUT'

contentType String

The content-type string value of the entity body, above; required when data is supplied.

headers Object

An object containing headers to set; supported headers are: 'Accept', 'If-Match' and 'If-None-Match'.

success function

A callback function executed on a 200 success status code.

error function

A callback function executed when a HTTP status error code is returned.

experimental Boolean false

If this is set to true, the developer acknowledges that the API endpoint which is being called may be in beta state, and thus may also have a shorter deprecation cycle than stable APIs.

// A simple POST request which logs response in the console.
  url: '../assets/js/rest-example.json',
  type: 'POST',
  data: {name: 'some text', description: 'test'}
  success: function(responseText){
  error: function(xhr, statusText, errorThrown){
// Upload an attachment to a Confluence entity.
var fileToUpload = document.getElementById("fileInput").files[0];

  url: '/rest/api/content/123456/child/attachment',
  type: 'POST',
  contentType: 'multipart/form-data',
  data: {comment: 'example comment', file: fileToUpload},
  success: function(responseText){