I have to integrate Avaya IVRS with Service now through java rest web-service. If user calls through Avaya IVRS, he should have option to choose from menu via their phone keypad and do the following functions :- 1. Add a ticket 2. Update a ticket 3. Close a ticket I have written code to create and update ticket but i don't know how to integrate with service now.
/////////////////////////////////////////////////
// POST OPERATION -- Create a new Incident ticket
/////////////////////////////////////////////////
String endpointPOST = baseURI + "/in";
PostMethod post = new PostMethod(endpointPOST);
post.addRequestHeader("X-AccessKey", accessKey);
post.addRequestHeader("Accept" , "application/xml");
post.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
post.setRequestBody("<in>" + "<customer COMMON_NAME=\"System_SD_User\"/>" +
"<description>Created from REST API Java Samples code</description>" + "</in>");
try {
System.out.println("Execute POST request for " + endpointPOST);
// Execute POST request
int result = client.executeMethod(post);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
System.out.println(post.getResponseBodyAsString());
System.out.println();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
post.releaseConnection();
}
//////////////////////////////////////////////////////
// PUT OPERATION -- Update an existing Incident ticket
//////////////////////////////////////////////////////
String endpointPUT = baseURI + "/in/400001";
PutMethod put = new PutMethod(endpointPUT);
put.addRequestHeader("X-AccessKey", accessKey);
put.addRequestHeader("Accept" , "application/xml");
put.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
put.setRequestBody(
"<in>" + "<summary>Updated from REST API Java Samples code</summary>" + "</in>");
try {
System.out.println("Execute PUT request for " + endpointPUT);
// Execute PUT request
int result = client.executeMethod(put);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
System.out.println(put.getResponseBodyAsString());
System.out.println();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
put.releaseConnection();
}