You are viewing limited content. For full access, please sign in.

Question

Question

Uploading a file self hosted

asked on October 11, 2023 Show version history

I'm trying to automate some bulk uploads to our self hosted install.

The file I'm uploading via swagger is a 65 byte file It uploads with a error 409 but it gives back the error.

{
  "operations": {
    "entryCreate": {
      "entryId": 556124,
      "exceptions": []
    },
    "setEdoc": {
      "exceptions": []
    },
    "setTemplate": {
      "template": null,
      "exceptions": [
        {
          "errorCode": 9066,
          "errorClass": "extraErrorException",
          "statusCode": 409,
          "operationId": "6de271ffa78344ce88d28f819a17fb22",
          "message": "One or more required fields were omitted or had a blank value. [9066]",
          "errorSource": "Laserfiche Server"
        }
      ]
    },
    "setFields": {
      "fieldCount": 0,
      "exceptions": [
        {
          "errorCode": 216,
          "errorClass": "invalidRequest",
          "statusCode": 400,
          "errorSource": "Api Server",
          "operationId": "6de271ffa78344ce88d28f819a17fb22",
          "message": "Error: Given value is not a valid option in the list of items for field Document Type.",
          "instanceDetail": "metadata.fields.Document Type"
        },
        {
          "errorCode": 9054,
          "errorClass": "extraErrorException",
          "statusCode": 409,
          "operationId": "6de271ffa78344ce88d28f819a17fb22",
          "message": "Bad field: Department. Another operation on which this operation depends failed. [9054]",
          "errorSource": "Laserfiche Server"
        },
      More Omitted, identical to above with each field.
      ]
    }
  },
  "documentLink": "https://redacted/LFRepositoryAPI/v1/Repositories/DEV--Cityof/Entries/556124"
}

The first error I think is related to setting the template and it says template: null in the error.

 

 

A full fields of a file that was uploaded with the web interface.
 

{
  "@odata.context": "https://redacted/LFRepositoryAPI/v1/$metadata#Collection(Laserfiche.Repository.EntryFieldValue)",
  "value": [
    {
      "@odata.type": "#Laserfiche.Repository.FieldValue",
      "fieldId": 48,
      "fieldName": "Department",
      "fieldType": "List",
      "isMultiValue": false,
      "isRequired": false,
      "hasMoreValues": false,
      "groupId": 0,
      "values": [
        {
          "value": "Legislative Services",
          "position": 0
        }
      ]
    },
    {
      "@odata.type": "#Laserfiche.Repository.FieldValue",
      "fieldId": 49,
      "fieldName": "Document Type",
      "fieldType": "List",
      "isMultiValue": false,
      "isRequired": false,
      "hasMoreValues": false,
      "groupId": 0,
      "values": [
        {
          "value": "Brochure",
          "position": 0
        }
      ]
    },
    {
     MORE Ommited
    }
  ]
}

My body looks like

{
  "template": "Main",
  "metadata": {
    "fields": {
      "Department": {
        "values": [
          {
            "value": "IT",
            "position": 0
          }
        ]
      },
      "Document Type": {
        "values": [
          {
            "value": "Brochure",
            "position": 0
          }
        ]
      },
      "Original Creation Date": {
        "values": [
          {
            "value": "1980-04-21",
            "position": 0
          }
        ]
      }
    },
    "tags": [
    ],
    "links": [
    ]
  },
  "volumeName": ""
}

I thought it might just be that it doesn't like setting a template because of the document type, but you can see this is the exact value I got from looking at another entity.

 

0 0

Answer

SELECTED ANSWER
replied on October 12, 2023

For the API, we have the check to see if the value is in the "List Items" for List field type, I think that's the reason causing the error. We would fix it to have the same behavior as web client in future release.

In the meanwhile, could you try to change the field type for "Document Type" and "Department" to Text? It would not have the check

2 0

Replies

replied on October 12, 2023

Hi,

Seeing from the error messages, for the first one, it seems that there is one or more required fields in the template, and you might omit or have give blank value for them.

For the other 2 would need more information to see what's the cause. For the "Document Type" and "Department" fields, are they configured as dynamic fields with external table?

0 0
replied on October 12, 2023

Department and Document Type are both Dynamic Fields pulling from external tables.

 

Document Type has a Parent Field of Department. My guess is that it's can't set the template because of required fields and it can't set the fields because they depend on each other as external lookups? Do I have to do this as many requests or what is the work around?

Screenshot 2023-10-12 121217.png
0 0
replied on October 12, 2023

I've been digging more. In our system the main template under general has department and document type as list  but with only Blank as an option (image attached) and then Dynamic Fields with the same name.

If I have an item in laserfiche (not via the API) but don't give it a template then add the loose fields Department and Document Type the document Type doesn't populate and just gives me the option of Blank.

 

When I set the template to Main it removes these loose fields and their values and replaces then with blank unset fields.

 

So is there a way to upload files setup like this via the API?

 

Screenshot 2023-10-12 123558.png
0 0
replied on October 12, 2023

Setting all the required fields during upload and using blank for the Document Type let me upload the file and assign the template except the document type is "Blank".

In the web client I can change the document type to any from the drop down but when I try to change it via the API

PUT 'https://REDACTED/LFRepositoryAPI/v1/Repositories/REDACTED/Entries/556128/fields'

{
  "type": "invalidRequest",
  "title": "Error: Given value is not a valid option in the list of items for field Document Type.",
  "status": 400,
  "instance": "/v1/Repositories/REDACTEd/Entries/556133/fields",
  "operationId": "e2c90b50107f4469a3116ce2a3513373",
  "errorSource": "Api Server",
  "errorCode": 216,
  "traceId": "00-0068d7dc82671d286a13abb9c46846c3-08a6e05293728e33-00"
}

So it looks like because this update and upload operation both remove all fields and re add them it doesn't like the dynamic fields. Is there a work around?

0 0
SELECTED ANSWER
replied on October 12, 2023

For the API, we have the check to see if the value is in the "List Items" for List field type, I think that's the reason causing the error. We would fix it to have the same behavior as web client in future release.

In the meanwhile, could you try to change the field type for "Document Type" and "Department" to Text? It would not have the check

2 0
replied on October 12, 2023

Thank you I'll ask the business owners to okay this change and test it

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.