-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
The server responds 500 if the request body is null #235
Comments
Hello @BossZou , The usage of ☝️ Required Body ENDPOINT("GET", "/collections/{collection_name}/partitions", ShowPartitions,
PATH(String, collection_name), // <--- required parameter!
QUERIES(QueryParams, query_params), // <--- can be empty because it's a set of params.
BODY_STRING(String, body)) // <--- required parameter!
{
return createResponse(Status::CODE_200, "OK");
} Optional BodyIn order to have an "optional body" in endpoint, you can do the following ENDPOINT("GET", "/collections/{collection_name}/partitions", ShowPartitions,
PATH(String, collection_name),
QUERIES(QueryParams, query_params),
REQUEST(std::shared_ptr<IncomingRequest>, request))
{
try {
auto body = request->readBodyToString();
// todo
} catch (...) {
// currently readBodyToString() throws std::runtime_error.
// But it should be, and might be changed to oatpp::web::protocol::http::HttpError
}
return createResponse(Status::CODE_200, "OK");
} Ignored BodyIf you don't want to process the body at all - just remove the ENDPOINT("GET", "/collections/{collection_name}/partitions", ShowPartitions,
PATH(String, collection_name), // <--- required parameter!
QUERIES(QueryParams, query_params)) // <--- can be empty because it's a set of params.
{
return createResponse(Status::CODE_200, "OK");
} Regards, |
Hey @BossZou , Please note that starting from oatpp QUERIES(const QueryParams&, query_params) //<--- Compilation Error Use the following instead: QUERIES(QueryParams, query_params) //<--- const & added automatically Please find the full changelog here - https://github.com/oatpp/oatpp/blob/master/changelog/1.1.0.md Regards, |
Closing this issue... |
I compile with oatpp source code on branch master, and define a endpoint as follows:
And I tried to send a request without any pay-load:
I received a error:
However, I tried to compile with previous version of oatpp (such as v0.19.11), server work well.
The text was updated successfully, but these errors were encountered: