How can I call rpc method with named parameters?
thuhuwei opened this issue · 3 comments
For example:
{"jsonrpc":"2.0", "method": "subtract", "params":{"subtrahend": 23, "minuend": 42}, "id": 3}
I don't find such examples in TestClient. Thanks!
You look like you've got it already, that came right out of the examples in the spec. http://www.jsonrpc.org/specification#examples
Anything there should work for you. Are you getting an error?
You can check out the wiki or look on this page: https://github.com/Astn/JSON-RPC.NET/blob/master/AustinHarris.JsonRpcTestN/Test.cs
for "ObjectSyntax"
You will see things like:
[Test()]
public void TestOptionalParamDouble_2ndPresentObjectSyntax()
{
string request = @"{method:'TestOptionalParamdouble_2x',params:{input1:123, input2: 671},id:1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
Assert.IsFalse(result.Result.Contains("error"));
Assert.AreEqual(expectedResult, result.Result);
}
Nice to see your response. I'm developing a c# winform application, which will call a remote json rpc method with named parameters. I saw examples in TestClient, and I found that I could not define the parameter name in the class JsonRequest, which is defined as
public class JsonRequest
{
public JsonRequest();
[JsonProperty("id")]
public object Id { get; set; }
[JsonProperty("method")]
public string Method { get; set; }
[JsonProperty("params")]
public object Params { get; set; }
}
I'm not familiar with JSON-RPC. Look forward to the answer. Thanks.
You should be able to set Params to be a POCO you have created and attributed with JsonProperty attributes. When you have Json.net serialize the JsonRequest it should do the right thigh then.
I'm going to close this issue as its more of a question. Not really a feature request, or a bug. I suggest Stack overflow if you have more questions