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.
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.