[ofbiz-plugins] branch trunk updated: Improved: Added 400 for POST requests with no request body(OFBIZ-11328)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-plugins] branch trunk updated: Improved: Added 400 for POST requests with no request body(OFBIZ-11328)

grv-2
This is an automated email from the ASF dual-hosted git repository.

grv pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 42192da  Improved: Added 400 for POST requests with no request body(OFBIZ-11328)
42192da is described below

commit 42192da7d3cc8bd979711e72a47b104dda0c25a3
Author: Girish Vasmatkar <[hidden email]>
AuthorDate: Thu Sep 10 10:36:44 2020 +0530

    Improved: Added 400 for POST requests with no request body(OFBIZ-11328)
---
 .../java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
index 5a58610..b55b16f 100644
--- a/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
+++ b/ofbiz-rest-impl/src/main/java/org/apache/ofbiz/ws/rs/resources/OFBizServiceResource.java
@@ -128,6 +128,9 @@ public class OFBizServiceResource extends OFBizResource {
     @Produces(MediaType.APPLICATION_JSON)
     public Response invokeServiceByPost(HashMap<String, Object> serviceInParams, @PathParam(value = "serviceName") String serviceName)
             throws IOException, GenericEntityException, GenericServiceException {
+        if (UtilValidate.isEmpty(serviceInParams)) {
+            throw new BadRequestException("The request body is missing.");
+        }
         ServiceRequestProcessor processor = new ServiceRequestProcessor();
         return processor.process(
                 UtilMisc.toMap("serviceName", serviceName, "httpVerb", HttpMethod.POST, "requestMap", serviceInParams, "dispatcher", getDispatcher(),