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

Question

Question

Cloud API Preview / PostEntryWithEdocMetadataRequest

asked on November 13, 2020

Digging into the nuts and bolts of the preview - for the basics of uploading a file into LF Cloud, the byte representation of a file is the byte equivalent.  I get that.

 

However, the documentation notes that the Form Parameters are as follows:

electronic Document : byte[]

request : PostEntryWithEdocMetadataRequest

 

Is there more to the POST that I should be prototyping? e.g.  I can find no explanation of "PostEntryWithEdocMetadataRequest" and didn't know if there was more to it.

 

Right now, my understanding is that to completely get a document uploaded, I would

1 POST the byte version of the doc

2. receive the LFID for the doc

3. THEN assign the Template, Template Field / Variables

 

Though drastically simplified, is that pretty much the flow?

 

Mark

1 0

Replies

replied on November 13, 2020 Show version history

Hey Mark,

 

Great to hear you're trying things out. The flow you described can work, but we do support setting the metadata in the same upload API call too. Unfortunately, it looks like our reference isn't showing the actual details of the request. We'll be sure to patch that up in the reference material.

 

In the meantime, you can view the schema of PostEntryWithEdocMetadataRequest in the swagger site in the Schemas section here: https://api.laserfiche.com/repository/swagger/index.html

 

You can also see an example request body once you hit the "Try it out" button in the UI:

Here's another example in action:

{
    "template" : "Email",
    "metadata" : {
        "fields" : {
            "Subject" : {
                "values" : [
                    {
                    "value" : "Hello",
                    "position" : 1
                    }
                ]
            }
        }
        "tags" : [
            "SampleTag"
        ]
    }
}

 

Please don't hesitate to ask any other questions as you continue to look through.

 

Best

2 0
replied on November 20, 2020

Thanks for the udpate: is there any more documentation / details regarding the structure of the template update object json?

 

e.g. the " "template" : "Email" " structure in the thread. 

I can probably figure it out, but I always prefer the real documentation.

 

Thanks!

1 0
replied on December 2, 2020

Alex, et al -

Thanks again for the heads up on this, but is there any additional documentation on the JSON field/value structure for the templates?  I can try and stumble my way through it, but I always feel better having some actual backup for the code level decisions we make.

 

(e.g. is "position" required when posting a field value, etc)

 

Thanks!

 

1 0
replied on December 3, 2020

Hey Mark,

Here's another example with more comments. The template is simply the name of the template. It will automatically assign all of the fields that belong to the template to the entry.

We expose the fields section if you wanted to also set some of the field values (or for instance, if you have a Required field in the template, you would have to set the value at this time). The more complicated structure is the set of fields, which is a dictionary of the fields that you want to set values for.

{
    "template" : "Email", //the name of the template
    "metadata" : {
        "fields" : {
            "Subject" : { //the key to this dictionary is the name of the field. In this case, the field named "Subject"
                "values" : [
                    {
                    "value" : "Hello",
                    "position" : 1 //Currently it is required to set the position (which is 1-indexed) even for a field that isn't a multi-value field
                    }
                ]
            },
			"Sender" : { //the key to this dictionary is the name of the field. In this case, the field named "Sender"
                "values" : [
                    {
                    "value" : "sender@email.com",
                    "position" : 1 
                    }
                ]
            },
			"Recipients" : { //the key to this dictionary is the name of the field. In this case, the field named "Recipients"
                "values" : [
                    {
                    "value" : "recipient1@email.com",
                    "position" : 1 
                    },
                    {
                    "value" : "recipient2@email.com", 
                    "position" : 2  //This is a multi-value field, so we can set multiple values using different position values
                    }
                ]
            }
        }
    }
}

 

We're experimenting with different tools to generate our reference material so your feedback is greatly appreciated. It also looks like we may want to rethink how these fields are set up. A list of field dictionaries would make more sense, and position should maybe only be required for multi value fields.

0 0
replied on December 3, 2020

Alex,

Thanks for the feedback / update - keep those dribs and drabs coming!

Yes, I agree that the having the position optional for single valued fields would make more sense.  In the context of single valued fields, will the json entry STILL be an array, or will it change?

 

e.g. from your example, with field "recipient" having a single value of  "recipient1@email.com"

 

 

0 0
replied on December 15, 2020

Sorry Mark, I thought I sent a response to this but it was sitting idle. That field value will remain an array, even if it's not a MV field. We wouldn't want to define a different schema for every different possible field.

 

Mind if I ask what you're looking to build and what kind of environment you are sending these calls from? Is there a reason why are you constructing these raw json requests rather than working in a specific programming language?

 

We are looking into publishing client libraries for the API in languages like C# and javascript. You can put your language of choice in the Preview survey if you haven't already taken it. The API is also OpenAPI compliant so you could generate a client library in the language of your choice.

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

Sign in to reply to this post.