0

I need an help. My problem is making api with JSON RPC 2.0 on .net core 2.0 project. So, i've installed this https://github.com/edjCase/JsonRpc plugin. And set ItemsController like this:

namespace AWSTestLambda.Controllers
{
    [Route("api/v1/[Controller]")]
    public class ItemsController : RpcController
    {
        public String Test(int id)
        {
            return "testing";
        }
    }
}

So, i call the method with postman on local like this (on local machine):

URL set on POST: http://localhost:55241/api/Items

And like body set (raw):

{
    "jsonrpc": "2.0",
    "method": "Test",
    "params": {
        "id": 1234
    },
    "id": ""
} 

The response is:

{
    "id": "",
    "jsonrpc": "2.0",
    "error": {
        "code": -32601,
        "message": "No methods matched request.",
        "data": null
    }
}

How can solve this problem ? I don't know like call the method inside the controller. Thanks all.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mr. Developer
  • 3,295
  • 7
  • 43
  • 110
  • Try using the address `http://localhost:55241/api/v1/Items/Test` because your controllers route is `api/v1/Items` and your calling the `Test` method on it – MindSwipe Jun 04 '19 at 06:04
  • @MindSwipe excuse me but, the json rpc not need it to set controller on url to call, right ? Or i should add the name controller also in the url to call and also into "method" proprertie when i call – Mr. Developer Jun 04 '19 at 12:29
  • You're not calling the controller directly. You're initiating a get request to a URI. And your controller Method `Test` has the URI `http://localhost:55241/api/v1/Items/Test` and because it's a get request the entire URI will look like this: `http://localhost:55241/api/v1/Items/Test?id=1234` – MindSwipe Jun 04 '19 at 13:56

1 Answers1

1

Try to change post url to http://localhost:55241/api/v1/Items. You have set yout route [Route("api/v1/[Controller]")] but you are calling http://localhost:55241/api/Items.