There isn't a working Base64 encode function in Dashboard unfortunately, it does look like you're on the right track.
What method of authentication does the API require? - basic auth, OAuth, etc. Does the server require authentication before sending a key in reply before accepting messages?
Perhaps break the message down to begin with, create a simple auth POST and send this to the server, what responses does it return? - are there any error codes?
You can convert messages to Base64 in Notepad++ if you require this for an auth message.
Original Message:
Sent: 06-23-2024 22:14
From: Sakito Okamoto
Subject: HTTP ASync Post with Authorization and Raw body.
var requestURL = "http://xxx.xxx.xxx.xxx/api/xxxxx/xxxx";
var credentials = "admin" + ":" + "xxxxxxx";
ogscript.debug(credentials);
var credentials64 = base64Encode(credentials);
ogscript.debug("base64Encode =" + credentials64);
params.setValue('Base64', 0, credentials64);
var creds = "Basic " + params.getValue('Base64', 0);
var headers = {};
headers["Authorization"] = creds;
headers["Content-Type"] = "application/json";
var bodyData = JSON.stringify({
"command": "xxxxxxxxx",
"deviceType": "xxxxxxxx",
"params": {"key": "xxxxxxxxxx"},
"devices": ["xxxxxxxxxxxxx"]
});
ogscript.asyncHTTP(requestURL, "POST", headers , bodyData, null);
I'm trying with this script.
According to Dsah Board debugger, Base64 encoding is not working.
I don't have any idea what's wrong with this.
Does someone have idea to fix?
------------------------------
Sakito Okamoto
Marketing
Ascent
Original Message:
Sent: 06-19-2024 02:19
From: Sakito Okamoto
Subject: HTTP ASync Post with Authorization and Raw body.
Hello everyone.
Could someone help me?
I'm trying to send API command to third party Signage server.
I usually do it with HTTP ASync Post with URL.
Most of them don't need Authrization and body(maybe command body?)
But some of them need it, and I don't have an idea how to insert these information.
Please see body sample below:
{"command":"samplecom","deviceType":"sampletype","params":{"key":"cancel"},"devices":["deviceID"]}
Authorization username and password must be included in a header.
API calling URL: http://[ServerIP]/api/pat/actions-
Sorry for lack of basic knowledge for API things.
Sakito.
------------------------------
Sakito Okamoto
Marketing
Ascent
------------------------------