For the life of me, I can't figure out why I'm getting an XML parsing error for the action URL of a Twilio response object. I've attached both the output page error and the java code I use to generate the XML.
OUTPUT ERROR
XML Parsing Error: not well-formed
Location: https://test.ignore.com/ApplicationName/go.acx?action=ivr.outbound.twilio.Introduction&rkey=1
Line Number 4, Column 101:<Response><Gather action="instanceurl.com/AccessWorx/go.acx?action=ivr.outbound.twilio.Selection&rkey=1" timeout="5" numDigits="1" finishOnKey="#" method="GET"><Say>This is an automated message from __________ to notify you of a service issue.Here is a sample message. Press 1 to accept this serviceissue, Press 2 to forward this call to the next contact in you company, press 3 if you are not the correct person to contact, press 4 to repeat these options.</Say></Gather></Response>
----------------------------------------------------------------------------------------------------^
The ^ doesn't match up in the above code formatting but its essentially pointing at the "=" sign in rkey=1 at the end of the action url.
JAVA CODE
StringBuffer sb = new StringBuffer();
sb.append("This is an automated message from ___________ to notify you of a service issue.")
.append(serviceMessage)
.append("Press 1 to accept this service"
+ "issue, Press 2 to forward this call to the next contact in you company, press 3 "
+ "if you are not the correct person to contact, press 4 to repeat these options.");
// Create a TwiML response and add our friendly message.
TwiMLResponse twiml = new TwiMLResponse();
Say say = new Say(sb.toString());
Gather g = new Gather();
// set url to selection with paramter for rkey
IVRAgent ivrAgent = new IVRAgent();
g.setAction(ivrAgent.buildActionUrl(callBean.getInstanceUrl() + "go.acx?", "ivr.outbound.twilio.Selection", rkey.toString()));
g.setTimeout(TIMEOUT);
g.setNumDigits(1);
g.setFinishOnKey(POUND);
g.setMethod("GET");
try {
g.append(say);
twiml.append(g);
} catch (TwiMLException e) {
log.error("Error in creating twiml", e);
e.printStackTrace();
}