MashZone NextGen 10.2 | Appendix | Legacy Presto components | MashZone NextGen 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 MashZone NextGen attributes to have the MashZone NextGen Server resolve parameter values. See Map MashZone NextGen Attributes to Artifact Input Parameters for more information.
*Remove or add MashZone NextGen 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 MashZone NextGen send the result in CSV, JSON or XML format. If you don’t add this header, MashZone NextGen returns the response in the native format of the mashable for mashup.
*x-p-anonymous=true to have MashZone NextGen treat this request as coming from a guest user with no identity.
*Headers to have MashZone NextGen 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 MashZone NextGen 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-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release