Yes, it is different but I have it working for the most part.
Just need to get the variable into the setRequestHeader, but it seems to fail regardless of how I build the string.
var CLIENTID = Watch.GetVariable("global.ClientID");
xhr.setRequestHeader('client-id', 'Insert CLIENTID here');
“It seems to fail” doesn’t give me much to go on.
The syntax you are using appears correct, assuming you meant to write something like this:
var CLIENTID = Watch.GetVariable("global.ClientID");
xhr.setRequestHeader('client-id', CLIENTID);
But without additional context, I can’t help you much. Here’s a couple of pointers, though:
Make sure you use setRequestHeader()after the open() and before the send() calls.
When a client-id/client-secret are embedded in request headers like this, it is almost certain that the URL requires you to use https (not http). Check with the documentation of the server you are attempting to reach.
I did get it to work, but not sure why. I deleted the lines and typed them in. The command did evolve and at some point I had used cut & paste with the values, so I guess there was a hidden character somewhere.
var CLIENTID = Watch.GetVariable("global.ClientID");
var CLIENTSECRET = Watch.GetVariable("global.ClientSecret");
xhr.setRequestHeader('client-id', CLIENTID);
xhr.setRequestHeader('client-secret', CLIENTSECRET);