Back

How to get IFormCollection from Context.Req.Body or Context.Req.BodyRaw in .net function

  • 0
  • Functions
Abhishek
19 Mar, 2024, 18:46

Hello, I trying to build an appwrite function in .net 7.0. Frontend is sending the formData with multipart file. Therefore, in the function, I need to convert the request body to IFormCollection body but I'm not able to do so. I need help here.

TL;DR
Developers in .net 7.0 trying to get IFormCollection from Context.Req.Body are encountering an InvalidCastException. To resolve this, consider using `Request.Form` to retrieve the form collection.
Abhishek
19 Mar, 2024, 18:47
TypeScript
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Microsoft.AspNetCore.Http.IFormCollection'.
   at DotNetRuntime.Handler.Main(RuntimeContext Context) in /usr/local/server/src/Index.cs:line 12
   at DotNetRuntime.Program.Action(HttpRequest request) in /usr/local/server/src/Program.cs:line 193
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more