cancel
Showing results for 
Search instead for 
Did you mean: 

REST API error running Data Publication

RickyCartner
Contributor III

I am trying to run a data feed Javascript Transport  file that will trigger data publications to run via the recently available internal APIs; however, the data feed keep Failing with the message: "The script execution failed due to an un-expected error" (or a similar message). I have tried to include several Try/Catch statements, but have not been able to find where it is erroring. 

But the most odd part is that the data publications will run even if the data feed fails. Here is the section of the Javascript that runs the DPS.

 

 

function runDataPublication(token, dpsID, callback) {
	try {
		httpRequest.get(
			{
				url: "https://localhost.com/RSAarcher/api/V2/internal/DataPublications(" + dpsID + ")/_RunNow",
				headers: {
					"Content-Type": "application/json;charset=UTF-8",
					"Authorization": "Archer session-id=" + token
				},
				strictSSL: false
			}, function (error, response, body) {
				if (error) {
					callback(error.toString());
				}
				else if (response.statusCode == 200) {

					callback(JSON.parse(body).statusText);
				}
				else {
					callback("There was another error");
				}

			});
	}
	catch (err) {
		callback("Try-Catcher error received: " + err);
	};
};

 

 

 

When I tried to run the same API via the API Template, I receive a 200 status, but also an error at the top of the page. However, this time, it does NOT trigger the DPS. 

Data Publication Error.png
 
Is there some other type of error handling that I can include in my script to catch this error?
 
Edit: I found the problem with the API Template. I needed to start the url with "/api/"... and exclude the "host name/RSAarcher" from the beginning. 
Still working on why the javascript function will run the DPS but still return an error.
0 REPLIES 0