creecros / MetaMagik

Custom Fields for Kanboard - Plugin MetaMagik
MIT License
98 stars 16 forks source link

using API with MetaMagic #76

Closed Shahin-rmz closed 1 year ago

Shahin-rmz commented 2 years ago

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

creecros commented 2 years ago

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 commented 2 years ago

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

creecros commented 2 years ago

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

otherwise, I cant help you.

Shahin-rmz commented 2 years ago

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 commented 2 years ago

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.

creecros commented 2 years ago

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.

Shahin-rmz commented 2 years ago

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.

creecros commented 2 years ago

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.

ulrischa commented 1 year ago

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

creecros commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.

ulrischa commented 1 year ago

Ok i will try it with the latest from this repo

ulrischa commented 1 year ago

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 commented 1 year ago

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

creecros commented 1 year ago

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

creecros commented 1 year ago

well, im getting stumped.

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

creecros commented 1 year ago

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

creecros commented 1 year ago

now it is all set.

ulrischa commented 1 year ago

I will try it tonight or tomorrow

creecros commented 1 year ago

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

ulrischa commented 1 year ago

Cool! Thank you very much

ulrischa commented 1 year ago

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

creecros commented 1 year ago

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.

ulrischa commented 1 year ago

Oh no I used createTask. Thanks