Hi again @btribbia, and thanks for responding.
Yes that is exactly how I have it. Below is the code. It is failing and that is because it didnt get the cookie. The API works if i tested it on its own. I must not be passing the cookie right?!
var assert = require(‘assert’);
var request = require(‘request’);
var apiResponse = ‘’;
var myJar = $http.jar();
var FirstAPIOptions = {
url: “https://www.website.com/api/FirstApi”,
body: ‘some body’,
headers: {
‘User-Agent’:‘curl/7.43.0’,
‘Content-Type’: ‘application/json’
},
jar: myJar
};
// Callback
function FirstAPICallback(err, response, body) {
console.log("FirstAPI status code: " + response.statusCode);
console.log('FirstAPI Response: ', body);
if(response.statusCode == 200)
{
var cookie = myJar.getCookies(FirstAPIOptions.url);
console.log("cookie: " + cookie);
apiResponse = JSON.parse(body);
if(apiResponse.responseActionUrls.length == 1)
{
$http.post(SecondAPIOptions, SecondAPICallback);
//console.log(‘blah’);
}
}
else
{
assert.equal(response.statusCode, 200, ‘FirstAPI did not return a 200 response’);
}
}
var SecondAPIOptions = {
url: “https://www.website.com/api/SecondAPI”,
body: ‘some body’,
headers: {
‘User-Agent’:‘curl/7.43.0’,
‘Content-Type’: ‘application/json’
},
jar: myJar
};
// Callback
function SecondAPICallback(err, response, body) {
console.log("SecondAPI status code: " + response.statusCode);
console.log('SecondAPI response: ', body);
if(response.statusCode == 200)
{
apiResponse = JSON.parse(body);
}
else
{
assert.equal(response.statusCode, 200, ‘SecondAPI did not return a 200 response’);
}
}
$http.post(FirstAPIOptions, FirstAPICallback);