diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 957fcfdaa7..e8342b18d5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -62,7 +62,7 @@ public interface ConsumerRESTAPIServices { throws APIServicesException, BadRequestException, UnexpectedResponseException; ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, - String supportedGrantTypes, String callbackUrl) + List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException; KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 55f3c7003f..e5608d5cbc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -729,7 +729,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, - String supportedGrantTypes, String callbackUrl) + List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException { ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); @@ -746,16 +746,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + tokenInfo.getAccessToken()); } - String payload = "{\n" + - " \"keyMappingId\": \"" + keyMapId + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"supportedGrantTypes\": [\n" + - " \"" + supportedGrantTypes + "\"\n" + - " ],\n" + - " \"callbackUrl\": \"" + callbackUrl + "\",\n" + - " \"additionalProperties\": {}\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, payload); + JSONArray supportedGrantTypeList = new JSONArray(); + for (String string : supportedGrantTypes) { + supportedGrantTypeList.put(string); + } + + JSONObject payload = new JSONObject(); + payload.put("keyMappingId", keyMapId); + payload.put("keyManager", keyManager); + payload.put("supportedGrantTypes", supportedGrantTypeList); + payload.put("callbackUrl", (callbackUrl != null ? callbackUrl : "")); + payload.put("additionalProperties", new JSONObject()); + + RequestBody requestBody = RequestBody.create(JSON, payload.toString()); builder.put(requestBody); Request request = builder.build();