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

Question

Question

What to put in the custom boundary field for Web Request in Cloud?

asked on May 17, 2024

What do we put in the Custom Boundary field when creating a Web Request rule to upload a file?

0 0

Answer

SELECTED ANSWER
replied on May 20, 2024

Basically "Custom Boundary" should be a unique string to avoid collisions with other strings in the body.

For example, if  "Custom Boundary" = --BoundaryLsAEJjn1nj0ojjzB

Then Content Body would look like

----BoundaryLsAEJjn1nj0ojjzB
Content-Disposition: form-data; name="file"; filename="placeholder.%(Name: FileExtension; Type: Text)"
Content-Transfer-Encoding: binary

%(Name: ImportFile; Type: File)
----BoundaryLsAEJjn1nj0ojjzB
Content-Disposition: form-data; name="request"

 {
        "autoRename": true,
        "metadata": {
            "tags": [ ]
        },
       "importAsElectronicDocument": true,
        "name": "%(Name: FileName; Type: Text)"
    }
----BoundaryLsAEJjn1nj0ojjzB--

 

2 0
replied on May 20, 2024

Thanks Paolo!

0 0
replied on June 27, 2024

Thanks Paolo!  Exactly what i was looking for too.

0 0
replied on June 27, 2024

Hi Paolo, 

Got a sight problem with the end-point returning the following error:-

Have tried adding the Content-Type into the Header rows, but this is overridden by the Content area's Content Type (presumably) by LF.

Is there another way around this, to your knowledge, please?  I really don't want to start chunking the JSON file in as a text token!

Thanks!

Justin

 

0 0
replied on July 8, 2024

Hi Justin, not sure what kind of file you are trying to upload. The example below uploads a json file using Repository API v2 via Web Request Rule. What's important is to use the correct file extension (.json) to identify the file content.

0 0
replied on July 9, 2024

Thanks for your reply, Paolo.

I'm trying to upload a JSON file (fairly simple structure) to a web API.

I've tried to follow your example above (removing the use-case specific bits) and the issue appears to be that the Content-Type request header is not "application/json" as it has to explicitly be "multipart/form-data" in order to allow the "File" token type.

I've added in the Accept header, per your example above as well.

Sadly, still being rejected!
 

0 0
replied on July 12, 2024

Hi Justin, we just published a new user guide Using the Laserfiche API from Workflows and Business Processes via Web Request Rules in a Laserfiche Cloud Account .

This is not a direct answer to your question but the guide includes a "Laserfiche Repository API - Entry - Import - Web Request Rule.bri" file that you can import in your account. I tested this Web Request Rule to successfully import a json file into a Laserfiche cloud repository.

1 0
replied on October 3, 2024

Thank you Paolo - just picked up on this and will give it a read and try it out.

 

Best wishes,
Justin
 

0 0

Replies

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

Sign in to reply to this post.