Я пытаюсь загрузить документы через 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#
Место общения программистов C#
1730292987
Anonymous
Я пытаюсь загрузить документы через 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/dotnet/core/compatibility/aspnet-core/8.0/antiforgery-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; }
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79141204/uploading-files-as-part-of-a-larger-form-submission-in-a-single-request-minimal[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия