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

Question

Question

LF API Server - Property file not found in the request body

asked on November 23, 2023 Show version history

Hi all,

A client of ours has recently starting using the self-hosted API server. They're trying to use the following request to create new documents in Laserfiche via the API.

When doing this through the Swagger interface the request is successful and creates the document as expected. Running the same request from the application they wish to integrate with (developed in C#) the request fails.

Each time it fails there is an error logged in the API trace log (%ProgramData%\Laserfiche\API Server\LFRepositoryAPI\Logs\trace.log) which states "Property file not found in the request body". I'll copy the full error below. There is also a warning about MaxRequestBodySize, but I think this can be ignored as we also receive this for successful requests (maxAllowedContentLength and uploadReadAheadSize both set to 100 MB in IIS).

As it works through Swagger I'm guessing this is either an issue with how the document is being passed into the request or something tampering with the request before it gets to the API (the other application is in a DMZ so there are firewalls/anti-virus between the applications).

Has anyone seen this issue before? Or does anyone know precisely what the above error means?

Many thanks!

Dan

 

Full Error:

2023-11-22 08:14:08.2295||TRACE|TraceLogger|[LFRepositoryAPI]HTTP Reponse: 200.[9e58c167f98e41dbb5a6f02c327fb7e7][0!0](1s 201ms)>[Verbose][-1][8000002b-0003-ec00-b63f-84710c7967bb][system] 
2023-11-22 08:14:08.2295||WARN|Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer|Increasing the MaxRequestBodySize conflicts with the max value for IIS limit maxAllowedContentLength. HTTP requests that have a content length greater than maxAllowedContentLength will still be rejected by IIS. You can disable the limit by either removing or setting the maxAllowedContentLength value to a higher limit. 
2023-11-22 08:14:08.4636||WARN|TraceLogger|[LFRepositoryAPI]Error: Invalid Request. Property file not found in the request body.[b1ffdf4f0aa3445cb5b1b0a524118664][1!0](231ms)>[Warning][-1][8000002c-0003-ec00-b63f-84710c7967bb][system]
Message: Error: Invalid Request. Property file not found in the request body.
Type: Laserfiche.Repository.LFSConnector.Exceptions.InvalidRequestException
StackTrace:    at Laserfiche.Repository.LFSConnector.Connectors.EntryConnector.ValidateFileSizeForImport(IFormFile file, Boolean notAllowEmptyFile)
   at Laserfiche.Repository.LFSConnector.Connectors.EntryConnector.CreateEntryWithEdocAndMetadata_V1(String repositoryId, Int32 parentEntryId, String fileName, IFormFile file, PostEntryWithEdocMetadataRequest request, Boolean autoRename)

1 0

Answer

SELECTED ANSWER
replied on November 23, 2023

Hi,

In v1, the name of the property in the request body is "electronicDocument", not "file", as mentioned in the swagger schema.

1 0
replied on November 28, 2023

Thanks Samad, that's great! The customer are using a .NET application to make the request, and they're using the below method.

Dim stream = New MemoryStream(file (byte array))
.Net.Http.MultipartFormDataContent.Add (New StreamContent(stream), "electronicdocument", fileName)

Is this the recommended approach for adding the form data to the request?

Cheers!

Dan

0 0
replied on November 28, 2023

Hi,
Yes. It looks fine.
 

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.