Skip to content

Commit e3c8048

Browse files
merged post call fix
1 parent 651d312 commit e3c8048

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/main/java/Invokers/ApiClient.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,8 @@
2727
import java.text.DateFormat;
2828
import java.text.ParseException;
2929
import java.text.SimpleDateFormat;
30-
import java.util.ArrayList;
31-
import java.util.Collection;
32-
import java.util.Collections;
33-
import java.util.Date;
34-
import java.util.HashMap;
35-
import java.util.List;
36-
import java.util.Map;
30+
import java.util.*;
3731
import java.util.Map.Entry;
38-
import java.util.Properties;
39-
import java.util.TimeZone;
4032
import java.util.concurrent.TimeUnit;
4133
import java.util.regex.Matcher;
4234
import java.util.regex.Pattern;
@@ -1393,7 +1385,15 @@ public void callAuthenticationHeader(String method, String path, Object body, Li
13931385

13941386
Authorization authorization = new Authorization();
13951387

1396-
String requestBody = json.serialize(body);
1388+
String requestBody = null;
1389+
if ((method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT") ||
1390+
method.equalsIgnoreCase("PATCH"))
1391+
&& body.equals("{}")) {
1392+
requestBody = "{}";
1393+
} else {
1394+
requestBody = json.serialize(body);
1395+
}
1396+
13971397
logger.debug("HTTP Request Body:\n" + requestBody);
13981398
merchantConfig.setRequestData(requestBody);
13991399
authorization.setJWTRequestBody(requestBody);
@@ -1489,7 +1489,11 @@ public Request buildRequest(String path, String method, List<Pair> queryParams,
14891489
reqBody = RequestBody.create(MediaType.parse(contentType), "");
14901490
}
14911491
} else {
1492-
reqBody = serialize(body, contentType);
1492+
if (body.equals("{}")) {
1493+
reqBody = RequestBody.create("{}", MediaType.parse(contentType));
1494+
} else {
1495+
reqBody = serialize(body, contentType);
1496+
}
14931497
}
14941498

14951499
Request request = null;

0 commit comments

Comments
 (0)