Skip to content

Commit 94a4954

Browse files
committed
handle form-data
1 parent 642c5e9 commit 94a4954

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ApiToolKit.cs

+12
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ public async Task InvokeAsync(HttpContext context)
9797
requestBody = JsonConvert.SerializeObject(dictionary);
9898

9999
}
100+
else if (contentType != null && contentType.StartsWith("multipart/form-data"))
101+
{
102+
try
103+
{
104+
var form = await context.Request.ReadFormAsync();
105+
var formData = form.ToDictionary(x => x.Key, x => x.Value.ToString());
106+
requestBody = System.Text.Json.JsonSerializer.Serialize(formData);
107+
108+
}
109+
catch (Exception) { }
110+
}
111+
100112
var payload = _client.BuildPayload("DotNet", stopwatch, context.Request, statusCode,
101113
System.Text.Encoding.UTF8.GetBytes(requestBody), System.Text.Encoding.UTF8.GetBytes(responseBody),
102114
responseHeaders, pathParams, urlPath, errors, msg_id);

0 commit comments

Comments
 (0)