Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

To use "application/x-www-form-urlencoded" with readBodyDtoAsync #76

Open
remioukrat opened this issue Dec 20, 2022 · 1 comment
Open

Comments

@remioukrat
Copy link

If we want to a consume DTO like this
info->addConsumes<Object<MyDTO>>("application/x-www-form-urlencoded");

when we try to read DTO like this
return request->readBodyToDtoAsync<Object<MyDTO>>(controller->getDefaultObjectMapper()).callbackTo(&MyClass::MyCallback);

There is a problem with the bodyDecoder and the callback is not called.

@lganzzzo
Copy link
Member

Hello @remioukrat ,

when we try to read DTO like this
return request->readBodyToDtoAsync<Object>(controller->getDefaultObjectMapper()).callbackTo(&MyClass::MyCallback);
There is a problem with the bodyDecoder and the callback is not called.

That's because you are trying to make JSON mapper to read application/x-www-form-urlencoded

You have to read body to string first, and then parse that body on your own.

return request->readBodyToString().callbackTo(&MyClass::MyCallback);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants