Appendix : Legacy Presto components : Business Analytics Development and APIs : Working with theMashZone NextGenREST API : Build and Send the Request
Build and Send the Request
Take the URL from the Technical Specs for the mashable or mashup and:
*Update any of the parameters, as needed.
You can set parameter values programmatically, or use Business Analytics attributes to have the Business Analytics Server resolve parameter values. See Map Business Analytics Attributes to Artifact Input Parameters for more information.
*Remove or add Business Analytics Headers/Parameters to control aspects of request processing or specific information in the response.
Some of the most common headers include:
*x-p-resultFormat to have Business Analytics send the result in CSV, JSON or XML format. If you don’t add this header, Business Analytics returns the response in the native format of the mashable for mashup.
*x-p-anonymous=true to have Business Analytics treat this request as coming from a guest user with no identity.
*Headers to have Business Analytics paginate the response.
*Headers to override the credentials to use for a secure connection with a mashable.
Mashables are registered with credential information when the service requires authentication, but you can override these default credentials using Business Analytics headers.
Using jQuery, for example, the request would look something like this:
var requestBody = '';
var params = "p=" + this.zip;
var headers= "x-p-resultFormat=json&x-p-anonymous=true";

var invokeUrl = "/mashzone/edge/api/rest/YahooWeatherREST/getData?" + headers + "&" + params;

jQuery.ajax({
type: "get",
contentType: "application/x-www-form-urlencoded",
url: invokeUrl,
data: requestBody,
dataType: "text",
success: function(response){
var result = response;
if(typeof response !== "string") {
result = Object.toJSON(response);
}
jQuery("#result").val('' + result);//show response
},
error: function(xhr, errorStatus, e) {
jQuery("#result").val(xhr.responseText);//handle error
}
});
If the mashable or mashup uses HTTP POST, you must also build the body of the request to match what the mashable or mashup is expecting.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback