Goal : to make it work in newrelic
curl -X POST -F <data1> -F <data2> -F <data3> <URI>
Find substring 'Successful' on the result page
-------------------
API test should be created in newrelic. Code:
var assert = require('assert');
var options = {
body: "field1=data1&field2=data2",
headers: {
'Content-Type': 'application/x-www-formurlencoded'
}
};
//Define expected results using callback function.
function callback(error, response, body) {
//Log status code to Synthetics console.
console.log(response.statusCode + " status code")
//Verify endpoint returns 200 (OK) response code.
var match_result = body.match(/Successful/);
assert.ok((response.statusCode == 200) && (match_result != null), 'Expected 200 OK response and "Successful" on the page');
//Log end of script.
console.log("End reached");
}
$http.post(options, callback);