What do we put in the Custom Boundary field when creating a Web Request rule to upload a file?
Question
Question
What to put in the custom boundary field for Web Request in Cloud?
Answer
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--
Thanks Paolo!
Thanks Paolo! Exactly what i was looking for too.
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
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.
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!
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.
Thank you Paolo - just picked up on this and will give it a read and try it out.
Best wishes,
Justin