Я пытаюсь загрузить документы через IFormFileCollection как часть отправки более крупной формы (в одном запросе). Каждый документ имеет дополнительные метаданные, такие как тип документа, имя документа и описание документа.
[img]https://i.sstatic. net/rBSBsMkZ.png[/img]
Получаю сообщение об ошибке:
Произошло необработанное исключение при выполнении запроса.
Microsoft.AspNetCore.Http.BadHttpRequestException: отсутствует необходимое значение для свойства LegalEntity.
Это моя полезная нагрузка:
{
"legalEntity": {
"name": "Acme Corporation",
"shortName": "Acme Corp",
"type": "Organization",
"registrationNumber": "REG123456",
"dateOfIncorporation": "2000-01-01T00:00:00",
"taxIdentificationNumber": "TAX987654",
"country": "United States",
"industryType": "Technology",
"creditLimit": 1000000.00,
"contactInformation": {
"primaryContactName": "John Doe",
"primaryContactPhoneNumber": "+1 (555) 123-4567",
"primaryContactEmail": "john.doe@acmecorp.com",
"secondaryContactName": "Jane Smith",
"secondaryContactPhoneNumber": "+1 (555) 987-6543",
"secondaryContactEmail": "jane.smith@acmecorp.com",
"website": "https://www.acmecorp.com"
},
"addressInformation": {
"street": "123 Tech Street",
"city": "Silicon Valley",
"state": "CA",
"postalCode": "94000"
},
"bankInformation": {
"accountName": "Acme Corporation Operating Account",
"accountNumber": "1234567890",
"swiftCode": "TECHUS123",
"iban": "DE89370400440532013000",
"bankAddress": "456 Bank Street, Silicon Valley, CA 94000, USA"
},
"kycInformation": {
"status": "Pending",
"riskRating": "Low",
"amlStatus": "Compliant",
"sanctionsCheckStatus": "Passed",
"complianceNotes": "Initial compliance review completed",
"parentCompany": null,
"documents": [
{
"documentType": "Certificate of Incorporation",
"documentName": "acme_incorporation.pdf",
"documentDescription": "Certificate of Incorporation for Acme Corp"
}
]
},
"uboInformation": {
"name": "John Doe",
"ownershipPercentage": 100.00,
"nationality": "United States",
"identificationNumber": "123-45-6789"
}
}
}
Это конечная точка:
public class CreateLegalEntityEndpoint : IEndpoint
{
public static void MapEndpoint(IEndpointRouteBuilder endpoints)
{
ArgumentNullException.ThrowIfNull(endpoints);
endpoints.MapPost("/legalentities",
async ([FromForm] CreateLegalEntityCommand command, ISender sender, CancellationToken cancellationToken) =>
{
var result = await sender.Send(command, cancellationToken);
return result.Match(id => Results.Created($"/legalentities/{id}", id), CustomResults.Problem);
})
.Produces(StatusCodes.Status201Created)
.ProducesValidationProblem()
.ProducesProblem(StatusCodes.Status500InternalServerError)
.DisableAntiforgery() // See: https://learn.microsoft.com/en-us/dotne ... ery-checks
.WithTags(nameof(LegalEntity))
.WithOpenApi(operation => new OpenApiOperation(operation)
{
Summary = "Create a new legal entity",
Description = "Creates a new legal entity with all its related information"
});
}
}
public sealed record CreateLegalEntityCommand : IRequest
{
public required LegalEntityDto LegalEntity { get; init; }
public required IFormFileCollection Documents { get; init; }
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... st-minimal
Загрузка файлов как часть отправки более крупной формы в одном запросе (минимальные API) ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Загрузка файлов как часть отправки более крупной формы в одном запросе (минимальные API)
Anonymous » » в форуме C# - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Разорвите строку с разделителями и распечатайте элементы как часть более крупной строки.
Anonymous » » в форуме Php - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Получить число и его конечный текст (метрическую единицу измерения) из более крупной строки.
Anonymous » » в форуме Php - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-