Jump to content
View in the app

A better way to browse. Learn more.

Pulseway

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Posted

Hi,

I need assistance with getting this c# code to authenticate and list all devices.

I tried it with the username/password combo AND the token id/secret combo (token permissions are fully open)

I get the same error on both as seen here

{
  "Data": null,
  "Meta": {
    "TotalCount": 0,
    "ResponseCode": 403,
    "ErrorMessage": "A delegate registered to create instances of 'MM.Monitor.Application.ApiTokens.Services.Interfaces.IApiTokensDataService' returned null."
  }
}

Here's the Class in C#

using Newtonsoft.Json;
using RestSharp.Authenticators;
using RestSharp;
using System;


namespace Pulseway_Helper
{
    internal class GetDevices
    {
        private const string ENDPOINT = "https://api.pulseway.com/v3";
        private const string TOKEN_ID = "api_token_id_generated_in_pulseway";
        private const string TOKEN_SECRET = "api_token_secret_generated_in_pulseway";

        static void Main(string[] args)
        {
            // Create RestClientOptions and set the Authenticator
            var clientOptions = new RestClientOptions(ENDPOINT)
            {
                Authenticator = new HttpBasicAuthenticator(TOKEN_ID, TOKEN_SECRET)
            };

            // Initialize the RestClient with the options
            var client = new RestClient(clientOptions);

            // Create the request
            var request = new RestRequest("devices", Method.Get);

            // Add parameters to the request
            request.AddParameter("$top", "50");
            request.AddParameter("$skip", "0");

            // Execute the request
            var response = client.Execute(request) as RestResponse;

            // Get the content of the response
            var content = response.Content;

            // Deserialize the content
            dynamic result = JsonConvert.DeserializeObject(content);

            // Output the result (for demonstration purposes)
            Console.WriteLine(result);
        }
    }

}



 

ConsoleApp.cs

Edited by DeWaynes

Featured Replies

  • Administrators

Hey @DeWaynes

Thanks a mill for reaching out. 

Seeing as your request has a good bit of code, I'm going to open a support ticket for you so that our techs can review it better, so if it's not too much hassle please forward me your Pulseway email id so that I can CC you in the ticket and get your issue resolved!

Thanks 
Stefan 

  • 7 months later...

403 Error: Delegate Instance Null in Pulseway API Response

I'm encountering a 403 response when making a GET request to the Pulseway API to retrieve data. The error message indicates a delegate returned null for the IApiTokensDataService.
 

Request Details:
 

curl -X GET "https://api.pulseway.com/v3/organizations" -u "<TokenID>:<TokenSecret>"

Also tried 

curl -X GET "https://my-server-name.pulseway.com/v3/organizations" -u "<TokenID>:<TokenSecret>"

Response
{
  "Data": null,
  "Meta": {
    "TotalCount": 0,
    "ResponseCode": 403,
    "ErrorMessage": "A delegate registered to create instances of 'MM.Monitor.Application.ApiTokens.Services.Interfaces.IApiTokensDataService' returned null."
  }
}


I tried with other endpoints as well such as environments, and assets but got the same issue.

Could you please help?

@Anne 

Thanks,
Bharat K


 

Edited by Bharat
correction

Also tried Axios


With "https://my-server.pulseway.com/v3/organizations"; getting 404 and with "https://api.pulseway.com/v3/organizations"; getting 403 response 

const axios = require('axios');
 
const endpoint = "https://my-server.pulseway.com/v3/organizations";
const token_id = "token ID";
const token_secret = "token Secret";
 
const auth = {
username: token_id,
password: token_secret,
};
 
axios.get(endpoint, { auth })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
  • Administrators

Hey @Bharat - Can you confirm which application are you trying to retrieve the Pulseway data? And also, if you have generated the API access token from Pulseway?

  • 4 weeks later...

Hi @Mariale_Pulseway,

I am able to make API calls using the following URL:

  • https://my-server-name/api/v3/devices

However, this part of the documentation is quite confusing:

HTTP Request: https://api.pulseway.com/v3/Devices

If you host your own Pulseway Enterprise Server, use https://your-server-name/api/v3/ as the base URL.

I haven't hosted my own Pulseway server, yet I’m still unable to use the API at:

Is there another way to access a Pulseway trial without a self-hosted server?

Thanks!

Or could you please provide me examples of self-hosted servers and non-self-hosted server URLs in the browser or baseUrl?

Thanks!

  • 2 weeks later...

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.