Hi, I have a usecase if a Jira Service Management (Server) ticket closed, a SMS will be sent to reporter. Followed Using external APIs in SR - Adaptavist Library this tutorial to utilize Scriptrunner to hit the SMS API but errors appeared after.
import groovy.json.JsonOutput
import groovyx.net.http.ContentType
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
final externalUrl = "https://...........................com/"
def body = JsonOutput.toJson(
["to": "628138xxxxxxx",
"cc": "",
"bcc": "",
"message": "This is sample",
"subject": "",
"type": "0001"
])
def postResponse = post(externalUrl, "/int/notification/1.0.0/send", body)
/*
if (getResponse) {
def responsePostMap = postResponse as Map
responsePostMap.each {}
assert responseStatus == 200
}*/
def post (def hostUrl, def endpointAndQuery, def bodyJson)
{
def client = new RESTClient(hostUrl)
client.setHeaders([
'Accept' : ContentType.JSON,
'x-api-key' : 'token '
])
client.post(
path: endpointAndQuery,
contentType: ContentType.JSON,
body: bodyJson
)
}
please help me understand why
groovyx.net.http.ResponseParseException: status code: 200, reason phrase: OK
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:495)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.RESTClient.post(RESTClient.java:141)
at groovyx.net.http.RESTClient$post.call(Unknown Source)
at Script175.post(Script175.groovy:35)
at Script175.run(Script175.groovy:17)
Caused by: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is ‘�’ with an int value of 65533
Unable to determine the current character, it is not a string, number, array, or object