Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using API with MetaMagic #76

Closed
Shahin-rmz opened this issue May 13, 2022 · 25 comments
Closed

using API with MetaMagic #76

Shahin-rmz opened this issue May 13, 2022 · 25 comments

Comments

@Shahin-rmz
Copy link

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
Copy link
Owner

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
Copy link
Owner

for reference
#39

@creecros
Copy link
Owner

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
Copy link
Author

Shahin-rmz commented May 14, 2022

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
Copy link
Author

Shahin-rmz commented May 14, 2022

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 creecros reopened this May 14, 2022
@creecros
Copy link
Owner

creecros commented May 14, 2022

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
Copy link
Author

Shahin-rmz commented May 14, 2022

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
Copy link
Owner

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
Copy link

ulrischa commented Feb 1, 2023

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

@creecros
Copy link
Owner

creecros commented Feb 2, 2023

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
Copy link
Owner

creecros commented Feb 6, 2023

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 added a commit that referenced this issue Feb 6, 2023
@creecros
Copy link
Owner

creecros commented Feb 6, 2023

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
Copy link

ulrischa commented Feb 6, 2023

Ok i will try it with the latest from this repo

@ulrischa
Copy link

ulrischa commented Feb 6, 2023

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}}" https://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
Copy link

ulrischa commented Feb 6, 2023

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

@creecros
Copy link
Owner

creecros commented Feb 6, 2023

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

creecros added a commit that referenced this issue Feb 7, 2023
creecros added a commit that referenced this issue Feb 7, 2023
creecros added a commit that referenced this issue Feb 7, 2023
@creecros
Copy link
Owner

creecros commented Feb 7, 2023

well, im getting stumped.

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

@creecros creecros reopened this Feb 7, 2023
@creecros
Copy link
Owner

creecros commented Feb 7, 2023

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

@creecros
Copy link
Owner

creecros commented Feb 7, 2023

now it is all set.

@ulrischa
Copy link

ulrischa commented Feb 7, 2023

I will try it tonight or tomorrow

@creecros
Copy link
Owner

creecros commented Feb 7, 2023

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

@ulrischa
Copy link

ulrischa commented Feb 7, 2023

Cool!
Thank you very much

@ulrischa
Copy link

ulrischa commented Mar 5, 2023

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
Copy link
Owner

creecros commented Mar 5, 2023

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
Copy link

ulrischa commented Mar 5, 2023

Oh no I used createTask. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants