ogscript.asyncHTTP() with custom headers– script block silent, no logs

Hi all,

I’m trying to use ogscript.asyncHTTP() in a DashBoard panel button to send a GraphQL POST request to an external API endpoints that requires an Authorization: Bearer header. According to forum posts (e.g. James Peltzer’s 2021 reply) and the manual, I understand we can send custom headers by passing a JSON object in place of the Content-Type string.

ogscript.log(“Initializing GraphQL request…”);

function callback(result) {
ogscript.log(“Callback fired”);
try {
var response = JSON.parse(result);
ogscript.log("Parsed GraphQL response: " + JSON.stringify(response));
} catch (e) {
ogscript.log("Raw result: " + result);
}
}

var headers = {
“Authorization”: “Bearer xxxxxxxx”,
“Content-Type”: “application/json”
};

ogscript.log(“Headers and payload prepared.”);

var data = JSON.stringify({
query: mutation { DeviceRxChannelsSubscriptionSet(input: { deviceId: "c22ec0202cf148478be5977d4d6e0d4d", subscriptions: [ { rxChannelId: 1, rxChannelIndex: 1, subscribedDevice: "AVoIP-Church-Computer-OBS", subscribedChannel: "Left" }, { rxChannelId: 2, rxChannelIndex: 2, subscribedDevice: "AVoIP-Church-Computer-OBS", subscribedChannel: "Right" }, { rxChannelId: 3, rxChannelIndex: 3, subscribedDevice: "AVoIP-Church-Computer-OBS", subscribedChannel: "Center" }, { rxChannelId: 4, rxChannelIndex: 4, subscribedDevice: "AVoIP-Church-Computer-OBS", subscribedChannel: "LFEScreen" }, { rxChannelId: 5, rxChannelIndex: 5, subscribedDevice: "AVoIP-Church-Computer-OBS", subscribedChannel: "LeftSurround" }, { rxChannelId: 6, rxChannelIndex: 6, subscribedDevice: "AVoIP-Church-Computer-OBS", subscribedChannel: "RightSurround" } ] }) { ok } }
});

ogscript.log(“Sending asyncHTTP request…”);
ogscript.asyncHTTP(
“https://URL:443/graphql”,
“POST”,
headers,
data,
callback
);
What I’d Like Help With:

Does ogscript.asyncHTTP() support custom headers in my version of DashBoard (how can I confirm that definitively)?
I don’t understand how to follow and debug my script, what am I doing or not doing?

Thanks

Try defining the headers like this:

var headers = {};
headers[‘Authorization’] = ‘Bearer xxxxxxxx’;
headers[‘Content-Type’] = ‘application/json’;

Thank you so much Richard. I could be doing something wrong or misunderstanding how 3rd party control works in Dashboard. I tried what you recommended and that triggered nothing.

I am completely new to 3rd party control in dashboard but is there a walkthrough that you could link me on how to debug and control a 3rd party endpoint?

Ahmed,

Sorry for the delay. I am also quite new to Dashboard, but found the examples in this post very useful.

Facility Control

Rossvideo
remove preview

Facility Control

View the selected document’s details

View this on Rossvideo >

Hope this helps