Sending byte array

Aug 24, 2014 at 2:19 AM
Edited Aug 24, 2014 at 2:37 AM
I'm trying to send through json rpc a byte array.

I have built a method like this:
        public string UploadFile(string guid, string fileName, int bytesFrom, int bytesSize, byte[] content)
            return "Executed";
and try to send message like this:
Unfortunately server answers with an error like this:
    "message":"Internal Error",
      "Message":"Object type 'Newtonsoft.Json.Linq.JValue' cannot be converted to type 'System.Byte[]'.",
      "StackTraceString":"   w System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)\r\n   w System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)\r\n   w System.Reflection.RuntimeMethodInfo.UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   w System.Delegate.DynamicInvokeImpl(Object[] args)\r\n   w AustinHarris.JsonRpc.Handler.Handle(JsonRequest Rpc, Object RpcContext)",
      "ExceptionMethod":"8\nTryChangeType\nmscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.RuntimeType\nSystem.Object TryChangeType(System.Object, System.Reflection.Binder, System.Globalization.CultureInfo, Boolean)",
Can anybody help with this. How to send byte[] to server?
Sep 3, 2014 at 7:28 AM
I imagine the issue is that you are passing a string to a function that wants to deserialize it into a byte[]. The easiest thing would be to change you function to take a string, then do the conversion.

You can see in the error that it doesn't think it can convert the "Newtonsoft.Json.Linq.JValue" to a "System.Byte[]'. Its possible that we could try to do that conversion for you in this situation. If you think that still makes sense, then I suggest posting an issue over at GitHub. We are trying to move over to that site.