get( url, header, successCB, errorCB, [user], [password], [timeout], [certSource] ) method

Send an HTTP(S) GET request to a remote server.

This is a convenience function that simply calls sap.AuthProxy#sendRequest with "GET" as the method and null for the request body. All given parameters are passed as-is to sap.AuthProxy.sendRequest. The success callback is invoked upon any response from the server. Even responses not generally considered to be successful (such as 404 or 500 status codes) will result in the success callback being invoked. The error callback is reserved for problems that prevent the AuthProxy from creating the request or contacting the server. It is, therefore, important to always check the status property on the object given to the success callback.

Syntax

get( url, header, successCB, errorCB, [user], [password], [timeout], [certSource] ) → {function}

Parameters

Name Type Argument Description
url string   The URL against which to make the request.
header Object   HTTP header to send to the server.This is an Object. Can be null.
successCB sap.AuthProxy~successCallback   Callback method invoked upon a response from the server.
errorCB sap.AuthProxy~errorCallback   Callback method invoked in case of failure.
user string (optional) User ID for basic authentication.
password string (optional) User password for basic authentication.
timeout number (optional) Timeout setting in seconds.Default timeout is 60 seconds. A value of 0 means there is no timeout.
certSource Object (optional) Certificate description object.It can be one of sap.AuthProxy#CertificateFromFile, sap.AuthProxy#CertificateFromStore, or sap.AuthProxy#CertificateFromLogonManager.

Returns

A JavaScript function object to abort the operation. Calling the abort function results in neither the success or error callback being invoked for the original request (excepting the case where the success or error callback was invoked before calling the abort functino). Note that the request itself cannot be unsent, and the server will still receive the request - the JavaScript will just not know the results of that request.

Type:

function

Example

var successCB = function(serverResponse){
    alert("Status: " + JSON.stringify(serverResponse.status));
    alert("Headers: " + JSON.stringify(serverResponse.headers));
    if (serverResponse.responseText){
        alert("Response: " + JSON.stringify(serverResponse.responseText));
    }
}
var errorCB = function(errorObject){
    alert("Error making request: " + JSON.stringify(errorObject));
}
// To send a GET request to server, call the method
var abortFunction = sap.AuthProxy.get("http://www.example.com", null, successCB, errorCB);
// An example of aborting the request
abortFunction();
// To send a GET request to the server with headers, call the method
sap.AuthProxy.get("http://www.example.com", {HeaderName : "Header value"}, successCB, errorCB);
// To send a GET request to the server with basic authentication, call the method
sap.AuthProxy.get("https://www.example.com", headers, successCB, errorCB, "username", "password");
// To send a GET request to the server with mutual authentication, call the method
sap.AuthProxy.get("https://www.example.com", headers, successCB, errorCB, null, null, 0, 
    new sap.AuthProxy.CertificateFromLogonManager("theAppId"));

Source

authproxy.js, line 617.