title: Posting form file to ASP .NET Core API using AWS SDK Test Lambda Context and APIGatewayProxyRequest
body: <p>I have an ASP .NET Core API endpoint which accepts the below model:</p>
  <pre><code>public class FileUploadModel
  {
      public IFormFile? File { get; set; }
      public DateTime? Time { get; set; }
      public string Comment { get; set; }
  }
  </code></pre>
  <p>The project has been created via aws lambda template. I am trying to write a test scenario, which asserts the endpoint behavior when I am sending a request to it. For this purpose, I am using APIGatewayProxyFunction.</p>
  <p>Below is the test function:</p>
  <pre><code>[Fact]
  public async Task TestPost()
  {
      var lambdaFunction = new LambdaEntryPoint();
  
      var requestStr = File.ReadAllText(&quot;./SampleRequests/Files-Post.json&quot;);
      var request = JsonSerializer.Deserialize&lt;APIGatewayProxyRequest&gt;(requestStr, new JsonSerializerOptions
      {
          PropertyNameCaseInsensitive = true
      });
  
      request.Body = @&quot;{&quot;&quot;time&quot;&quot;:&quot;&quot;2022-04-27T20:00:00.000Z&quot;&quot;,&quot;&quot;comment&quot;&quot;:&quot;&quot;dummy comment&quot;&quot;}&quot;;
  
      // How to put file in request?
      
      var context = new TestLambdaContext();
      var response = await lambdaFunction.FunctionHandlerAsync(request, context);
  
      Assert.Equal(200, response.StatusCode);
      Assert.Equal(@&quot;{&quot;&quot;fileId&quot;&quot;:&quot;&quot;xxxxxxxxxx&quot;&quot;}&quot;, response.Body);
  }
  </code></pre>
  <p>My problem is that the APIGatewayProxyRequest accepts string as the request body, and I want to add a file to the request. How could I put a file alongside other inputs in the same request? Thanks</p>