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
