Getting Error-1505 Everytime I Try to Get Info from AP

Getting Error-1505 Everytime I Try to Get Info from AP

Getting Error-1505 Everytime I Try to Get Info from AP
Getting Error-1505 Everytime I Try to Get Info from AP
a week ago - last edited a week ago
Hardware Version:
Firmware Version: 6.0.0.25

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.

 

  0      
  0      
#1
Options
1 Accepted Solution
Re:Getting Error-1505 Everytime I Try to Get Info from AP -Solution
a week ago - last edited a week ago

Hello  @NeilR_M ,

 

I tested with super admin permission. It works now. But that wasn't the problem. Turns out site id was wrong. I thought site id was the same as site name. I used the call  "/openapi/v1/"omadaID"/sites?pageSize=100&page=1" to get the site ID and it works now. I should've read the document more carefully. Sorry about that. Thanks for the reply.

 

 

Recommended Solution
  0  
  0  
#3
Options
3 Reply
Re:Getting Error-1505 Everytime I Try to Get Info from AP
a week ago - last edited a week ago

  @Seagull96 Hello,

 

When creating the app in the Omada Controller, what role did you grant the App for your Controller? Is it possible to test the app with Super Admin permissions to see if it is a permission issue? 

  1  
  1  
#2
Options
Re:Getting Error-1505 Everytime I Try to Get Info from AP -Solution
a week ago - last edited a week ago

Hello  @NeilR_M ,

 

I tested with super admin permission. It works now. But that wasn't the problem. Turns out site id was wrong. I thought site id was the same as site name. I used the call  "/openapi/v1/"omadaID"/sites?pageSize=100&page=1" to get the site ID and it works now. I should've read the document more carefully. Sorry about that. Thanks for the reply.

 

 

Recommended Solution
  0  
  0  
#3
Options
Re:Getting Error-1505 Everytime I Try to Get Info from AP
a week ago

  @Seagull96 No worries! Happy your issue was resolved.

  0  
  0  
#4
Options