Slash Command - failed with error dispatch_failed

SAM321
Tera Contributor

Hi all, Iam trying to get the payload of slash command(/procurement) used in slack to servicenow log..But its showing error. as 

/procurement failed with the error "dispatch_failed"'
Below is the scripted rest Api.

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
 
    if (request.body.data.challenge){
response.setStatus(200);
response.setContentType('text/plain');
response.getStreamWriter().writeString(request.body.data.challenge);
 
}else{
if(request.body.data.event.text.contains('/procurement')){
gs.info('Slack Payload:'+ JSON.stringify(request.body.data));
 
}
}
 
})(request, response);

 

 

 

6 REPLIES 6

SAM321
Tera Contributor

@Mahesh23  no 

Community Alums
Not applicable

Hello, for anyone finding this thread in the future, I solved this issue by overriding the default supported request formats on the Scripted Rest Service record to allow application/x-www-form-urlencoded as follows.

 

DustinWatkins_0-1746649029699.png