API RpcClient

Hello

Edit: I’m a total C# beginner …

I have the following crash

Unhandled Exception: System.ArgumentException: Invalid salt
Parameter name: salt
  at BCrypt.Net.BCrypt.HashPassword (System.String input, System.String salt) [0x00000] in <filename unknown>:0 
  at BCrypt.Net.BCrypt.Verify (System.String text, System.String hash) [0x00000] in <filename unknown>:0 
  at ManagerServer.HttpHandlers.Rpc.Post () [0x00000] in <filename unknown>:0 
  at HttpFramework.HttpApplication.ProcessRequest (HttpFramework.HttpRequest request) [0x00000] in <filename unknown>:0 
  at ManagerServer.HttpApplication.ProcessRequest (HttpFramework.HttpRequest request) [0x00000] in <filename unknown>:0 
  at HttpFramework.HttpServer.Worker () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Invalid salt
Parameter name: salt
  at BCrypt.Net.BCrypt.HashPassword (System.String input, System.String salt) [0x00000] in <filename unknown>:0 
  at BCrypt.Net.BCrypt.Verify (System.String text, System.String hash) [0x00000] in <filename unknown>:0 
  at ManagerServer.HttpHandlers.Rpc.Post () [0x00000] in <filename unknown>:0 
  at HttpFramework.HttpApplication.ProcessRequest (HttpFramework.HttpRequest request) [0x00000] in <filename unknown>:0 
  at ManagerServer.HttpApplication.ProcessRequest (HttpFramework.HttpRequest request) [0x00000] in <filename unknown>:0 
  at HttpFramework.HttpServer.Worker () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 

on the server when I run the following program

using System;
using Manager;
using System.Linq;
      
namespace Hello_World
{
 public class Hello_World
 {
     public Hello_World()
     {     
     }
 
     public static void Main(string[] args)
     {
      var manager = new Manager.RpcClient()
      {
          Host = "localhost:8080",
          Username = "administrator",
          Password = ""
      };
      var response = manager.GetBusinesses();
      foreach (var e in response.Businesses)
      {
          Console.WriteLine(e.Name);
      }
     }
 }

}

compiled with

clear ; mcs /r:ManagerRPC.dll /r:protobuf-net.dll hello_world.cs

(note: I downloaded protobuf-net.dll from google-code and use r668 – the dll on the website has a typo and I can’t compile the simple program with it it gives me a “error CS0009: Metadata file `/home/eriam/ManagerApi/profobuf-net.dll’ does not contain valid metadata” error)

and the program is also crashing …

Unhandled Exception: System.Net.WebException: Error getting response stream (ReadDone2): ReceiveFailure ---> System.Exception:    at System.Net.WebConnection.HandleError(WebExceptionStatus st, System.Exception e, System.String where)
   at System.Net.WebConnection.ReadDone(IAsyncResult result)
  at System.Net.WebConnection.HandleError (WebExceptionStatus st, System.Exception e, System.String where) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.UploadDataCore (System.Uri address, System.String method, System.Byte[] data, System.Object userToken) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.UploadData (System.Uri address, System.String method, System.Byte[] data) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error getting response stream (ReadDone2): ReceiveFailure ---> System.Exception:    at System.Net.WebConnection.HandleError(WebExceptionStatus st, System.Exception e, System.String where)
   at System.Net.WebConnection.ReadDone(IAsyncResult result)
  at System.Net.WebConnection.HandleError (WebExceptionStatus st, System.Exception e, System.String where) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.UploadDataCore (System.Uri address, System.String method, System.Byte[] data, System.Object userToken) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.UploadData (System.Uri address, System.String method, System.Byte[] data) [0x00000] in <filename unknown>:0 

So any pointers would help !!

Thanks

Eriam

RpcClient is now obsolete.

On server edition, you can access JSON API by simply navigating to /objects and log in with user credentials which have administrator role.

So if your server is running on http://manager.mycompany.com then API will be at http://manager.mycompany.com/objects

The reason why I’m not doing C# library is because JSON API will allow access from any programming language and it’s easier to start with as you can traverse API with regular web-browser.

Thanks, I’m trying to POST to the JSON API – does the API supports POST / PUT / DELETE already ?

Hey,

As per this answer, it seems that posting is not up yet… But Lubos would be able to confirm. I’d like to know too!

It doesn’t but it would be easy to add. I’ll try to implement it in upcoming days.

@eriam, the latest version (16.4.56) supports POST, PUT and DELETE.

Also, since I’ve made some significant changes to API, it’s at new URL. Navigate to /api instead of /objects

Hey !

Thanks, I’ll try that asap.

Thanks

Hey. Just thought I’d point to this post about the python script I started on:

I need to push some more changes to that repo, but if you’d like to contribute, or if you start your own, let us know.