Hello there,
Just wondering if someone have already use the Java SDK to update or insert row into a datatable ...
I have been developping java code for customer where I need to update a row of a datatable. I'm calling the following method :
Map<String, Object> com.mypurecloud.sdk.v2.api.ArchitectApi.putFlowsDatatableRow(String datatableId, String rowId, Object body) throws IOException, ApiException
Update a row entryUpdates a row with the given rowId (the value of the key field) to the new values. The DataTableRow should be a json-ized' stream of key -> value pairs { "Field1": "XYZZY", "Field2": false, "KEY": "27272" }
Parameters:
datatableId id of datatable (required)
rowId the key for the row (required)
body datatable row (optional)Returns:
MapThrows:ApiException - if the request fails on the server
IOException - if the request fails to be processed
At first, I tried to use a String for the body:
String body = "{ " +
"\"LastExecutionDate\": \"" + lastExecutionDate + "\", " +
"\"LastExecutionStatus\": \"" + lastExecutionStatus + "\", " +
"\"LastExecutionErrorMsg\": \"" + lastExecutionDate + "\", " +
"\"ContactListId\": \"" + contactListId + "\", " +
"\"CSATUpperLimit\": \"" + CSATUpperLimit + "\", " +
"\"LastSurveyHandledDate\": \"" + lastExecutionDate + "\", " +
"\"key\": " + rowId + "} ";
But I'm getting an error on the execution.
So I looked up on Google on how to create a "JSON-ized" object and found multiple API for that.
I tried using json.org and my code looks like this :
ArchitectApi architectApiInstance = new ArchitectApi();
JSONObject body = new JSONObject();
body.put("LastExecutionDate", lastExecutionDate);
body.put("LastExecutionStatus", lastExecutionStatus);
body.put("LastExecutionErrorMsg", lastExecutionDate);
body.put("ContactListId",contactListId);
body.put("CSATUpperLimit", CSATUpperLimit);
body.put("LastSurveyHandledDate",lastExecutionDate);
body.put("key",rowId);
System.out.println("body = " + body);
architectApiInstance.putFlowsDatatableRow(datatableId, rowId, body);
When executing it, the output looks good:
body = {"LastExecutionDate":"","LastExecutionStatus":"PROCESSING","LastExecutionErrorMsg":"","ContactListId":"","CSATUpperLimit":1,"key":"UpdateBadCSATContactList","LastSurveyHandledDate":""}
But the code is throwing the following exception (same error as when using String object)
com.mypurecloud.sdk.v2.ApiException: error
at platform.client.v2@112.0.1/com.mypurecloud.sdk.v2.ApiClient.interpretConnectorResponse(ApiClient.java:567)
at platform.client.v2@112.0.1/com.mypurecloud.sdk.v2.ApiClient.getAPIResponse(ApiClient.java:580)
at platform.client.v2@112.0.1/com.mypurecloud.sdk.v2.ApiClient.invoke(ApiClient.java:673)
at platform.client.v2@112.0.1/com.mypurecloud.sdk.v2.api.ArchitectApi.putFlowsDatatableRow(ArchitectApi.java:8416)
I tried another JSON API, json-simple, and got the same error.
Anyone managed to build a proper "JSON-ized" object ?
Cheers,
Valéry