Page 1 of 1

Use REST API to create file with keywords included

PostPosted:Wed Jan 24, 2024 7:46 pm
by foundry
Hello, I have set up a javascript function to create a file in openKM. I am looking to add a keyword at the time of creation. The following code uploads a file to openKM, but does not apply keywords
Code: Select all
const form = new FormData();
    form.append('docPath', `/okm:root/${contentObj.name}`);
    form.append('content', contentObj, `${contentObj.name}`);

    const response = await fetch(`${OPENKM_API}/document/createSimple`, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Authorization': 'Basic ' + btoa('username:password')
        },
        body: form
    })
    .then((res) => {
        return res.json();
    });
What do I need to add in order to add keywords?

Re: Use REST API to create file with keywords included

PostPosted:Tue Jan 30, 2024 8:07 am
by jllort
You must request another method for it addKeyword -> https://github.com/openkm/document-mana ... e.java#L68

Re: Use REST API to create file with keywords included

PostPosted:Tue Jan 30, 2024 5:02 pm
by foundry
Thanks Jilort, I was hoping this could be done in one API call but this at least works.

Re: Use REST API to create file with keywords included

PostPosted:Tue Feb 06, 2024 7:49 am
by jllort
In the professional edition there's a plugin architecture with which you can extend the REST API methods ... unfortunately in the CE still we have not added this feature.