by Guest » 31 Dec 2024, 14:19
Versuche derzeit, 2 Bilder und einen String an eine API zu senden.
ApiCall:
Code: Select all
var data = new
{
mode = info
};
pathData = JsonConvert.SerializeObject(data.ToString());
var content = new MultipartFormDataContent
{
{ new StreamContent(frontStream), "front", front.FullName },
{ new StreamContent(backStream), "back", back.FullName },
{ new StringContent(pathData, Encoding.UTF8, "application/json") }
};
using var client = new HttpClient();
var response = await client.PostAsync($"https://localhost:987987987/Upload", content);
Ich habe es mit [FromBody] versucht und erhalte immer noch die Antwort „Nicht unterstützter Medientyp“.
Api:
Code: Select all
[HttpPost]
public async Task Post(IFormFile front, IFormFile back, [FromBody] string mode)
{
return Ok();
}
Versuche derzeit, 2 Bilder und einen String an eine API zu senden.
ApiCall:
[code]var data = new
{
mode = info
};
pathData = JsonConvert.SerializeObject(data.ToString());
var content = new MultipartFormDataContent
{
{ new StreamContent(frontStream), "front", front.FullName },
{ new StreamContent(backStream), "back", back.FullName },
{ new StringContent(pathData, Encoding.UTF8, "application/json") }
};
using var client = new HttpClient();
var response = await client.PostAsync($"https://localhost:987987987/Upload", content);
[/code]
Ich habe es mit [FromBody] versucht und erhalte immer noch die Antwort „Nicht unterstützter Medientyp“.
Api:
[code][HttpPost]
public async Task Post(IFormFile front, IFormFile back, [FromBody] string mode)
{
return Ok();
}
[/code]