Code Monkey home page Code Monkey logo

Comments (12)

RyanBuhrWA avatar RyanBuhrWA commented on September 21, 2024 1

See if the PATCH /documents/{documentId} API will solve this for you. It allows you to send an array of tags to a document and add or update all of them. Here's the documentation for it: Update Document API reference

from formkiq-core.

mfriesen avatar mfriesen commented on September 21, 2024 1

@Stason1o We will add this to our roadmap.

from formkiq-core.

Stason1o avatar Stason1o commented on September 21, 2024

@RyanBuhrWA , didn't see that functionality, was looking specifically on DocumentTags endpoints. I will try your suggestion today to see if it works fine for me and will come back with details later. Thanks!

from formkiq-core.

Stason1o avatar Stason1o commented on September 21, 2024

So, follow up to workaround @RyanBuhrWA mentioned with patch endpoint. I tried to send a payload, having only list of tags supplied, without content, and then, all getDocumentContent requests are failing with 500, but I couldn't find logs for the root cause of this( limited access to company CloudWatch) so, I guess this does not fit my case(unless I get access to CW and investigate logs).
Supplying everytime content could be resource heavy, having in mind that documents could be huge size, and rewriting same content everytime tags are updated is also not a good solution..
But anyway, thanks for helping!

Will stick to current implementation - looping through tags and calling PUT document tag one by one, until new endpoint is released

from formkiq-core.

mfriesen avatar mfriesen commented on September 21, 2024

@Stason1o Can you provide the request you sent using PATCH /documents/{documentId} and we can look into the 500 error you are seeing.

from formkiq-core.

Stason1o avatar Stason1o commented on September 21, 2024

@mfriesen Hi,
So basically the steps I am performing with document:

  1. Create document: POST: /documents with valid body - 200 Response
  2. Update Document, 2 steps:

Adding New tags( if they don't exist on document yet) using POST: /documents/{documentId}/tags
Updating Existing ones, using PATCH: /documents/{documentId}, with payload and getting 200 Response:

{
"tags": [
 {
    "key": "string",
    "value":"string",
 },
 {
    "key2": "string",
    "value2":"string",
 }
]

I am not supplying content for this request, because I don't have it fetched at that moment from Formkiq. Sending content as a part of this request will require addiitional GetDocumentContent, which is "redundand" for me, because I am working with tags only at that moment.

  1. Trying to get documentContent and this fails with 500 Response, indicating url, I was calling (could be our custom error response)

If I call GetDocumentContent before calling Patch Document, I receive 200 Response and document content. After calling Patch Document, and then GetDocumentContent - I get 500 response.
I suppose, that after calling Patch Document without supplying content in request body, FormKiq will set is as null? and this is causing issues on GetDocumentContent?

from formkiq-core.

mfriesen avatar mfriesen commented on September 21, 2024

Recently changes where introduced for POST /documents/{documentId}/tags, to support adding List of tags. I would like to suggest adding same support for updating multiple document tags in one request for PUT /documents/{documentId}/tags/{tagKey}

@Stason1o I assume you mean to add a PUT /documents/{documentId}/tags instead of /documents/{documentId}/tags/{tagKey}
with a body of
{
"tags": [ ... ]
}

which would replace all the tags in a document?

from formkiq-core.

Stason1o avatar Stason1o commented on September 21, 2024

@mfriesen, so basically I need an endpoint, which will accept body
{
"tags": []
}
and for each tag from request body, if this tag exists on document, its value will be updated to the value from request body.

Scenario:

  1. I have created a document with tags:[ id, type(img), subtype(nature)]
  2. I want to add additional tags to it. I use endpoint POST /documents/{documentId}/tags with body,
    containig new tags:
    {
    "tags": [case, comment, description, status(in_validation)]
    }. In result now document has list of tags:[id, type(img), subtype(nature), case, comment, description, status]
  3. Now I want to update some of the tags - type(png), subtype(city).
    With current version, I need to use PUT/documents/{documentId}/tags/{tagKey} and make a call for each tag I want to update and supply new value/values
    Feature request - have an endpoint which accepts tags:[] and updates exising tags with supplied value/values
    like PUT/PATCH /documents/{documentId}/tags
    {
    tags:[type(png), subtype(city)]
    }
    so I will make one request for updating multiple tag values at once, instead of calling formkiq service 20-30 times, depending on how many tags I need to update

Result - document tags are updated and document has tags:[id, type(png), subtype(city), case, comment, description, status]

from formkiq-core.

mfriesen avatar mfriesen commented on September 21, 2024

GetDocumentContent - I get 500 response. I suppose, that after calling Patch Document without supplying content in request body, FormKiq will set is as null? and this is causing issues on GetDocumentContent?

@Stason1o
Unfortunately I have been unable to duplicate the 500 issue you are experiencing. Would it be possible for you to look at the CloudWatch logs for the "DocumentsApi" lambda for a stack trace of the error you can send to me?

from formkiq-core.

Stason1o avatar Stason1o commented on September 21, 2024

@mfriesen So, I tried this morning and got same results.
Steps I performed:

  1. Create a document with child document POST: /documents
    addDocumentPayload.txt

Note: At this point GET /documents/{documentId} and GET /documents/{documentId}/content are working as expected.

  1. Update document tags(metadata), by calling update document endpoint PATCH /documents/{documentId}, by adding 4 new tags and 1 existing tag with body: { tags: [] }

updateDocumentPayload.txt

Response is 200.

  1. Perform call to GET /documents/{documentId}/content
    expected: 200 and content
    actual - 500 error:

logs.txt

from formkiq-core.

mfriesen avatar mfriesen commented on September 21, 2024

@Stason1o Thank you so much for the details. I'm still not able to replicate the issue.

Which version of FormKiQ are you using? From the logs, it looks like you are on v1.8.9?

from formkiq-core.

Stason1o avatar Stason1o commented on September 21, 2024

@mfriesen Yeah, it's 1.8.X (not sure about minor version), we will be migrating to newer version as soon as v1.12 will be out =)
Anyway, thanks for help.

from formkiq-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.