How to Register a New JSON-RPC Method (API) Using a Plugin #5525
-
Hello everyone, Can anyone guide me on how to:
Any code examples or links to relevant documentation would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
fguillot
Jul 31, 2024
Replies: 1 comment
-
Example to add a new JSON-RPC method <?php
namespace Kanboard\Plugin\MyPlugin;
use Kanboard\Core\Plugin\Base;
class Plugin extends Base
{
public function initialize()
{
$this->api->getProcedureHandler()->withCallback('myAPIProcedure', function($a, $b) {
return 'a + b = '.($a + $b);
});
}
} Example to call the new API procedure: curl -s \
-u admin:admin \
-d '{"jsonrpc": "2.0", "method": "myAPIProcedure", "id": 1, "params": {"a": 2, "b": 3}}' \
http://example.org/jsonrpc.php
{
"jsonrpc": "2.0",
"result": "a + b = 5",
"id": 1
} For reference: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fguillot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example to add a new JSON-RPC method
myAPIProcedure
with a plugin:Example to call the new API procedure:
For reference: