Getting Error-1505 Everytime I Try to Get Info from AP
I need help with Omada Software. I'm trying to get info from couple of AP110 that i have so i can use it on one of my apps. I did everything that is written on document but everytime i request i get an error.
{"errorCode":-1505,"msg":"The current user does not have permissions to access this site."}
I've a code written in c#.
using System.Net.Http;
using System.Text;
using System.Text.Json;
string omadacId = "omadacID";
string siteID = "siteID";
string MAC = "MAC";
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
using var client = new HttpClient(handler);
var tokenUrl =
"https://localhost:8043/openapi/authorize/token?grant_type=client_credentials";
var body = new
{
grant_type = "client_credentials",
omadacId,
client_id = "clientid",
client_secret = "clientsecret"
};
var tokenResp = await client.PostAsync(
tokenUrl,
new StringContent(
JsonSerializer.Serialize(body),
Encoding.UTF8,
"application/json"));
var tokenJson = await tokenResp.Content.ReadAsStringAsync();
Console.WriteLine(tokenJson);
using var doc = JsonDocument.Parse(tokenJson);
string accessToken = doc.RootElement.GetProperty("result").GetProperty("accessToken").GetString();
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.TryAddWithoutValidation(
"Authorization",
$"AccessToken={accessToken}"
);
var url =
$"https://localhost:8043/openapi/v1/{omadacId}/sites/{siteID}/aps/{MAC}";
var resp = await client.GetAsync(url);
var json = await resp.Content.ReadAsStringAsync();
Console.WriteLine(json);
Any input will be appreciated.
