MetaMagik icon indicating copy to clipboard operation
MetaMagik copied to clipboard

using API with MetaMagic

Open Shahin-rmz opened this issue 3 years ago • 8 comments

Hello, Thanks for the plugin. It is very useful for me.

Recently, I started to use Kanboard API with python to automate part of my job.

How ever, for the projects that I use cusom fields, I can not create a task with api. when I delete the custom fields of that project, the api works fine. I do not get any error so there are no logs. It just don't work.

Any idea how can I use api when using MetaMagic on a project? Thanks

Shahin-rmz avatar May 13 '22 21:05 Shahin-rmz

if metamagik is preventing api then there would be an error log somewhere. I've never had an issue, so I'd just be shooting blindly at a problem that seems to only exist on your end.

if you have more information, let me know.

creecros avatar May 13 '22 23:05 creecros

for reference https://github.com/creecros/MetaMagik/issues/39

creecros avatar May 13 '22 23:05 creecros

produce an error log, and I'll be happy to take a look. the api response would even help.

otherwise, I cant help you.

creecros avatar May 13 '22 23:05 creecros

produce an error log, and I'll be happy to take a look. the api response would even help.

That's exactly my problem. I do not get any errors. Could you please write a simple example with required custom field using Python wrapper, maybe I am doing something wrong. Thanks

what I need is combination of createTask() and saveTaskMetadata() in one command.

Shahin-rmz avatar May 14 '22 09:05 Shahin-rmz

I can update the custom fields when the the task is already made and task_id has been given. But creating metadata while making a task seems not possible as I can see.

Shahin-rmz avatar May 14 '22 09:05 Shahin-rmz

I'll test it out when I get time.

I dont know python though.

but, thinking about it, you may be right, you might not be able to do both in 1 command. but, again, if you read #39 you see where I talk about metamagik being a pretty face. it works with what is given from the base code. not to say it can't be done, but it's more a feature request and not an issue.

creecros avatar May 14 '22 10:05 creecros

I dont know python though.

curl will be enough. just to show how to add metadata while making a new task and I'll be good.

Shahin-rmz avatar May 14 '22 10:05 Shahin-rmz

if I never get around to this, which I will admit, my time is very limited: https://github.com/eSkiSo/Subtaskdate

I wrote api commands for this plugin. so you or anyone else could take cues, possibly come up with a solution.

creecros avatar May 14 '22 10:05 creecros

Sadly this is still an issue. Would love to use this plugin and be able to use the api

ulrischa avatar Feb 01 '23 20:02 ulrischa

can you tell me why you can't? https://docs.kanboard.org/v1/api/task_metadata_procedures/

I guess my question is, what are you missing? I mean, even based on the OP, worst case scenario, 1 api request to make a task, 1 api request to update the metadata. nothing is stopping that from working, as all these api's are built in.

creecros avatar Feb 02 '23 00:02 creecros

ok, after re reading this issue, i think my feeble brain has finally understood the issue.

if you have a custom field in a project that is "required" and you are using api to create a task, you can't.

Now I need to wrap my head around it.

creecros avatar Feb 06 '23 17:02 creecros

Give that a try, use api action "createTaskMeta" to create a task.

Currently it works exactly as "createTask" in KB core, but i added a switch so that the TaskCreationModel knows it is an API procedure, and will not try to add any custom fields.

This does not allow you to add custom fields during task creation through API, but should allow you to create a task at least.

It is untested. so I will be surprised if it works off that bat, if it does, damn im good at guessing.

creecros avatar Feb 06 '23 17:02 creecros

Ok i will try it with the latest from this repo

ulrischa avatar Feb 06 '23 17:02 ulrischa

I get this error curl -u "jsonrpc:TOKENHERE" -d "{"jsonrpc": "2.0", "method": "createTaskMeta", "id": 99999, "params": { "project_id": 1, "owner_id": 1,"title": "Test", "column_id": 2}}" http://localhost/kanboard/jsonrpc.php
Fatal error: Uncaught Error: Class "Kanboard\Plugin\MetaMagik\Api\Procedure\ProjectAuthorization" not found in C:\xampp81\htdocs\kanboard\plugins\MetaMagik\Api\Procedure\NewCreateTaskProcedure.php:26 Stack trace: #0 [internal function]: Kanboard\Plugin\MetaMagik\Api\Procedure\NewCreateTaskProcedure->createTaskMeta('Test', 1, '', 2, 1, 0, '', '', 0, 0, NULL, 0, 0, 0, 0, 0, 0, '', Array, '', NULL, NULL) #1 C:\xampp81\htdocs\kanboard\libs\jsonrpc\src\JsonRPC\ProcedureHandler.php(212): ReflectionMethod->invokeArgs(Object(Kanboard\Plugin\MetaMagik\Api\Procedure\NewCreateTaskProcedure), Array) #2 C:\xampp81\htdocs\kanboard\libs\jsonrpc\src\JsonRPC\ProcedureHandler.php(155): JsonRPC\ProcedureHandler->executeMethod(Object(Kanboard\Plugin\MetaMagik\Api\Procedure\NewCreateTaskProcedure), 'createTaskMeta', Array) #3 C:\xampp81\htdocs\kanboard\libs\jsonrpc\src\JsonRPC\Request\RequestParser.php(148): JsonRPC\ProcedureHandler->executeProcedure('createTaskMeta', Array) #4 C:\xampp81\htdocs\kanboard\libs\jsonrpc\src\JsonRPC\Server.php(372): JsonRPC\Request\RequestParser->parse() #5 C:\xampp81\htdocs\kanboard\libs\jsonrpc\src\JsonRPC\Server.php(321): JsonRPC\Server->parseRequest() #6 C:\xampp81\htdocs\kanboard\jsonrpc.php(5): JsonRPC\Server->execute() #7 {main} thrown in C:\xampp81\htdocs\kanboard\plugins\MetaMagik\Api\Procedure\NewCreateTaskProcedure.php on line 26

ulrischa avatar Feb 06 '23 20:02 ulrischa

I installed fresh kanboard and new metaMagic folder with all files from master branch here

ulrischa avatar Feb 06 '23 20:02 ulrischa

perfect, error code tells me what I forgot, ill update and we can try again.

creecros avatar Feb 06 '23 23:02 creecros

well, im getting stumped.

mine dies in the task validator. If I bypass the validator, it works fine. at least im close.

creecros avatar Feb 07 '23 16:02 creecros

and then i remembered I overrode the task validator....duh

creecros avatar Feb 07 '23 16:02 creecros

now it is all set.

creecros avatar Feb 07 '23 16:02 creecros

I will try it tonight or tomorrow

ulrischa avatar Feb 07 '23 17:02 ulrischa

sounds good, I actually tested it this time, so it should be straight.

creecros avatar Feb 07 '23 17:02 creecros

Cool! Thank you very much

ulrischa avatar Feb 07 '23 17:02 ulrischa

Just tested it: Still not possible to create tasks when MetaMagic is installed. I loaded ZIP here from GitHub. Runtime: Version: 1.2.26 PHP Version: 8.1.10 PHP SAPI: apache2handler HTTP-Client: cURL OS Version: Windows NT 10.0 Datenbanktreiber: sqlite Datenbank Version: 3.36.0

ulrischa avatar Mar 05 '23 19:03 ulrischa

you have to use the new api action. "createTaskMeta"

maybe you know that though, ill take a look, but it was working fine for me when I tested.

creecros avatar Mar 05 '23 19:03 creecros

Oh no I used createTask. Thanks

ulrischa avatar Mar 05 '23 20:03 ulrischa