Hi Everyone!
So I successfully used the POST endpoint /api/v2/voicemail/search in the API Explorer using the following query:
{
"query": [{
"fields": ["read","deleted"],
"type": "EXACT",
"value": "false"
},
{
"type": "EXACT",
"fields": ["owner"],
"value": "GROUP"
}
]
}
When I try to use that same query in the postVoicemailSearch(body) function from the Javascript SDK (version "purecloud-platform-client-v2": "^113.2.0") I get a "400 - BAD_REQUEST" error or a "400 - The request could not be understood by the server due to malformed syntax" depending on the format for the query in the body object. See comments in code below to identify when each error is returned (please note that if testing this code you have to uncomment any query object you would like to test because both queries are commented out):
function searchActiveOrgsForUnreadVoiceMail(orgConfig) {
const apiClientInstance = platformClient.ApiClient.instance;
let apiInstance = new platformClient.VoicemailApi();
apiClientInstance.setEnvironment(orgConfig.api_url);
apiClientInstance.loginClientCredentialsGrant(orgConfig.oauth_client_id, orgConfig.oauth_client_secret)
.then(()=> {
// Do authenticated things
console.log('Logged in successfully.');
let body = {
pageSize: 100,
pageNumber: 1,
/**************************
* WITH THIS query object I get error:
* statusCode: 400 - The request could not be understood by the server due to malformed syntax.
***************************/
// query: {
// fields: ['read, deleted'],
// type: 'EXACT',
// value: false,
// group: {
// fields: ['owner'],
// type: 'EXACT',
// value: 'GROUP'
// }
// }
/**************************
* WITH THIS query object I get error:
* statusCode: 400 - BAD_REQUEST
***************************/
// query: [{
// fields: ['read, deleted'],
// type: 'EXACT',
// value: 'false'
// },
// {
// type: 'EXACT',
// fields: ['owner'],
// value: 'GROUP'
// }
// ]
}; // Object | Search request options
return apiInstance.postVoicemailSearch(body)
})
.then((data) => {
// console.log(`postVoicemailSearch success! data: ${JSON.stringify(data, null, 2)}`);
console.log(data);
})
.catch((error) => {
// Handle failure response
loggerApi.error('Error in function searchActiveOrgsForUnreadVoiceMail. Logging details.');
loggerApi.error(error.body && error.body.status ? `${error.body.status} - ${error.body.message}` : error.body.message);
// sendJobExportErrorEmail(error);
});
}
Any ideas on how can I resolve this issue?