diff options
Diffstat (limited to 'redfish-core/include')
-rw-r--r-- | redfish-core/include/utils/json_utils.hpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp index b6885764cd..317cf11614 100644 --- a/redfish-core/include/utils/json_utils.hpp +++ b/redfish-core/include/utils/json_utils.hpp @@ -531,13 +531,27 @@ inline std::optional<nlohmann::json> BMCWEB_LOG_DEBUG << "Json value not readable"; return std::nullopt; } - - if (jsonRequest.empty()) + nlohmann::json::object_t* object = + jsonRequest.get_ptr<nlohmann::json::object_t*>(); + if (object == nullptr || object->empty()) { BMCWEB_LOG_DEBUG << "Json value is empty"; messages::emptyJSON(res); return std::nullopt; } + std::erase_if(*object, + [](const std::pair<std::string, nlohmann::json>& item) { + return item.first.starts_with("@odata."); + }); + if (object->empty()) + { + // If the update request only contains OData annotations, the service + // should return the HTTP 400 Bad Request status code with the + // NoOperation message from the Base Message Registry, ... + messages::noOperation(res); + return std::nullopt; + } + return {std::move(jsonRequest)}; } |