We are in the process to convert the applications to a new version of PP workflow (2022.2.3.5503) from old version of 8.7.1.12148 and we got some challenges here. We were using a JavaScript to create a object for Msxml2.XMLHTTP.4.0 to get the data: var xhr = new ActiveXObject(‘Msxml2.XMLHTTP.4.0’), but it is not working anymore. The error message is “Microsoft JScript runtime error: Automation server can’t create object”.
Try with
ActiveXObject("Msxml2.XMLHTTP.6.0")
or better yet, with
ActiveXObject("Msxml2.XMLHTTP")
Your IT has probably disabled XMLHTTP4 because of potential vulnerabilities.
Thanks, Phil for the reminder. That’s possible, I will have to check with our system administrators who had built the new web site in our new planet press server.
Morning Phil,
We have a piece of JavaScript here:
function retrieveDetailsForContentSet(contentsetId) {
var token = fetch({
method: ‘POST’,
url: ‘http://localhost:9340/rest/serverengine/authentication/login’,
headers: {
Authorization: ‘Basic b2wtYWRtaW46c2VjcmV0’ // 'Basic ’ + btoa(‘ol-admin:secret’)
}
})
var details = fetch({
method: ‘GET’,
url: ‘http://localhost:9340/rest/serverengine/entity/contentsets/’ + contentsetId + ‘/pages’,
data: { detail: true },
json: true,
headers: {
auth_token: token
}
})
return details
}
But, the two URLs are not working anymore. Any idea?
Thanks, John
You’d need to be a bit more precise than “URLs are not working” .
Do you get an error message, or a specific status code? The most obvious issue would be the authentication bit: providing the wrong credentials would result in a 40x status message.
You no longer need to specify the name/password in your code: you can use the Watch.GetConnectToken()
method to obtain a token based on the authentication settings you set in Workflow’s preferences.
For instance:
var connectInfo = JSON.parse( Watch.GetConnectToken() );
var res=null;
var xhr = new ActiveXObject("Microsoft.XMLHTTP");
xhr.open("GET", "http://localhost:9340/rest/serverengine/entity/contentsets/" + contentsetId + "/pages?detail=true", false);
xhr.setRequestHeader("auth_token", connectInfo.token);
xhr.send();
if(xhr.status==200) {
res = xhr.responseText;
}
Watch.Log(res,2);
Yes, Phil, let me elaborate it a bit more. We do have a fetch function called by the piece of code sent to you previously:
// Make an HTTP request
function fetch(options) {
//var xhr = new ActiveXObject(‘MSXML2.ServerXMLHTTP’)
var xhr = new ActiveXObject(“MSXML2.ServerXMLHTTP.6.0”);
var url = options.url
var method = options.method || ‘GET’
if (options.data && method === ‘GET’)
url += ‘?’ + queryString(options.data)
xhr.open(method, url, false)
if (options.headers) {
for (var name in options.headers) {
var value = options.headers[name]
xhr.setRequestHeader(name, value)
}
}
if (options.json)
xhr.setRequestHeader(‘Content-Type’, ‘application/json’)
if (options.data && method === ‘POST’)
xhr.send(queryString(options.data))
else
xhr.send()
if (xhr.status != 200)
throw new Error('XMLHTTP Error: ’ + xhr.status + ’ ’ + xhr.responseStatus)
if (options.json)
return JSON.parse(xhr.responseText)
return xhr.responseText
}
I was discussing the issue with our web administrators yesterday, the process stuck here:
if (xhr.status != 200)
throw new Error('XMLHTTP Error: ’ + xhr.status + ’ ’ + xhr.responseStatus)
And the error message we received was: “Error 0 on line 281, column 5: Microsoft JScript runtime error: XMLHTTP Error: 401 undefined”.
We are suspecting that the server agent account id which was running the workflow dos not have a proper access to the DLL of ActiveXObject(“MSXML2.ServerXMLHTTP.6.0”). They are investigating it. At the same time, I am checking with to see if you have some better ideas.
Thanks,
John
As i suspected, the problem is with authentication:
401 Unauthorized - HTTP | MDN (mozilla.org)
So make sure you are using the proper credentials or, as mentioned before, just use the Watch.GetConnectToken()
method
Thanks Phil. Can you please be a bit more specific regarding the authentication settings in Preferences tab:
We don’t know what/how to do there.
Thanks
Never mind, Phil, we got helped by Robert Otiniano today when we were discussing about another issue related the new printers. He suggested us to check the OL connect within the Preferences.
Hi Phil,
Sounds like we need to create an account ol-admin. However, we can’t remember we have ever use that credential in any of our scripts. Do we need to specifically add it somewhere in our scripts to make the DLL accessible? Or the system will automatically make the DLL accessible once the account being added into the pp server.
Thanks,
John
I don’t understand your question. What DLL do you want to access?
Or perhaps you mean the REST API? In which case you need to use the same credentials in your script (and in Workflow) as those that have been set in the Connect Server Configuration, shown here:
In Workflow, you specify those values in the OL Connect section of the preferences:
Once you have made sure those two sets of credentials match, then your scripts that call the REST API can simply use the Watch.GetConnectToken() method instead of specifying the username/password.
Sorry, Phil, I am on EDO and not working today. Just checked my email and found your response. The DLL I meant was ActiveXObject(“MSXML2.ServerXMLHTTP.6.0”) .
Thank you, I will pass on your information to our system administrators.
The “error” you are receiving is generated by your own script. The DLL is working perfectly fine: it tried to communicate with the server and the server returned a 401 status code, which means the credentials you specified are incorrect (and which also means the DLL is working fine since it was able to obtain a response from the server).
So for the fourth time: use the Watch.GetConnectToken()
method to get the authorization token.
If you are not comfortable making the changes yourself, please contact your reseller who can arrange for someone from our professional services team to make the changes for you.
Thanks Phil. After our system administrator added the ol-admin to the system, I just had another round of test, that error message “Error 0 on line 285, column 5: Microsoft JScript runtime error: XMLHTTP Error: 401 undefined” is finally gone, and I have not changed the script a bit.