Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FOUNDATIONS: Allow nullable value properties to be skipped or be part on the multipart-form #130

Open
Catalin-Andronie opened this issue May 7, 2023 · 0 comments

Comments

@Catalin-Andronie
Copy link
Contributor

Catalin-Andronie commented May 7, 2023

Currently we cannot construct a multipart-form for a model which has null or empty value properties.

public class Person
{
    [RESTFulStringContent(name: "firstName")]
    public string FirstName { get; set; }

    [RESTFulStringContent(name: "middleName")]
    public string? MiddleName { get; set; }
}

async Task MakeRequestAsync()
{
    var person = new Person
    {
        FirstName = "John Smith",
        MiddleName = null
    };

    var httpClient = SetupHttpClient();
    var apiClient = new RESTFulApiFactoryClient(httpClient);

    var response = await apiClient.PostFormAsync<Person, string>("/users", person);
}

Since no value was provided for middleName property, the next exception is thrown:

RESTFulSense.Models.Coordinations.Forms.Exceptions.FormCoordinationDependencyValidationException : Form coordination dependency validation error occurred, fix the errors and try again.
---- RESTFulSense.Models.Orchestrations.Forms.Exceptions.FormOrchestrationDependencyValidationException : Form orchestration dependency validation error occurred, fix the errors and try again.
-------- RESTFulSense.Models.Foundations.Forms.Exceptions.FormValidationException : Form validation error occurred, fix errors and try again.
------------ RESTFulSense.Models.Foundations.Forms.Exceptions.InvalidFormArgumentException : Invalid form arguments.Please fix the errors and try again.
Stack Trace:
at RESTFulSense.Services.Coordinations.Forms.FormCoordinationService.TryCatch(ReturningMultipartFormDataContentFunction returningMultipartFormDataContentFunction)
at RESTFulSense.Services.Coordinations.Forms.FormCoordinationService.ConvertToMultipartFormDataContent[T](T object)
at RESTFulSense.Clients.RESTFulApiFactoryClient.PostFormAsync[TContent, TResult](String relativeUrl, TContent content, CancellationToken cancellationToken)
// ...

@Catalin-Andronie Catalin-Andronie changed the title Allow or skip nullable values to be part of the multipart form Allow nullable value properties to be part of an multipart-form May 11, 2023
@Catalin-Andronie Catalin-Andronie changed the title Allow nullable value properties to be part of an multipart-form Allow nullable value properties to be skipped or be part on the multipart-form May 13, 2023
@Catalin-Andronie Catalin-Andronie changed the title Allow nullable value properties to be skipped or be part on the multipart-form FOUNDATIONS: Allow nullable value properties to be skipped or be part on the multipart-form May 17, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant