Skip to content

Commit

Permalink
handle form-data
Browse files Browse the repository at this point in the history
  • Loading branch information
dawkaka committed Sep 2, 2024
1 parent 642c5e9 commit 94a4954
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ApiToolKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ public async Task InvokeAsync(HttpContext context)
requestBody = JsonConvert.SerializeObject(dictionary);

}
else if (contentType != null && contentType.StartsWith("multipart/form-data"))
{
try
{
var form = await context.Request.ReadFormAsync();
var formData = form.ToDictionary(x => x.Key, x => x.Value.ToString());
requestBody = System.Text.Json.JsonSerializer.Serialize(formData);

}
catch (Exception) { }
}

var payload = _client.BuildPayload("DotNet", stopwatch, context.Request, statusCode,
System.Text.Encoding.UTF8.GetBytes(requestBody), System.Text.Encoding.UTF8.GetBytes(responseBody),
responseHeaders, pathParams, urlPath, errors, msg_id);
Expand Down

0 comments on commit 94a4954

Please sign in to comment.