• About the JavaScript API
  • AP
  • Cookie
  • Dialog
  • Events
  • History
  • Inline dialog
  • Flag
  • Messages (DEPRECATED)
  • Proxy request
  • Request

Proxy request

Methods

request (url, options)

Execute an XMLHttpRequest in the context of the host application, sent via the API proxy.

Parameters

Name Type Description
url String Either the URI to request or an options object (as below) containing at least a url property; should be relative to the context path of the host application.
options RequestProperties A RequestProperties object (see below for properties list).

Example

1
2
3
4
5
6
7
8
AP.require('proxyRequest', function(request){
  request({
    url: '/assets/js/rest-example.json',
    success: function(responseText){
      alert(responseText);
    }
  });
});

RequestProperties

An object containing the options of a request.

Properties

Name Type Description
url String the URL to request from the host application, relative to the host's context path
type String the HTTP method name; defaults to GET
cache Boolean if the request should be cached; default is true
data String the string entity 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
responseType String the response type this request will return. It defaults to json, however, it must be set to text when requesting a resource that does not return JSON, such as diffs, files, or logs.
headers Object an object containing headers to set; supported headers are Accept
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
  • System status
  • Privacy
  • Developer Terms
  • Trademark
  • Cookie Preferences
  • © 2019 Atlassian