rest api call node content type fix
[ccsdk/sli/plugins.git] / restapi-call-node / provider / src / main / java / org / onap / ccsdk / sli / plugins / restapicall / RestapiCallNode.java
index 8038b94..b93887f 100755 (executable)
@@ -788,8 +788,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
 
         WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl);
 
-        log.info("Sending request below to url " + p.restapiUrl);
-        log.info(request);
         long t1 = System.currentTimeMillis();
 
         HttpResponse r = new HttpResponse();
@@ -828,7 +826,15 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
             Response response;
 
             try {
-                response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType));
+                // When the HTTP operation has no body do not set the content-type
+                //setting content-type has caused errors with some servers when no body is present
+                if (request == null) {
+                    response = invocationBuilder.method(p.httpMethod.toString());
+                } else {
+                    log.info("Sending request below to url " + p.restapiUrl);
+                    log.info(request);
+                    response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType));
+                }
             } catch (ProcessingException | IllegalStateException e) {
                 throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e);
             }