Code
def post(def hostUrl, def endpoint, def body, def token) {
if (hostUrl.toString().contains('&') || hostUrl.toString().contains('?')) {
log.error 'The parameters of the endpoint must be included in the query variable'
return
}
def client = new RESTClient(hostUrl)
client.setHeaders([
'Accept' : ContentType.JSON,
'Authorization': "Bearer $token"
])
client.handler.success = { HttpResponseDecorator response, json ->
json
}
client.handler.failure = { HttpResponseDecorator response ->
log.error response.entity.content.text
[:]
}
client.post(
path: endpoint,
body: body,
contentType: ContentType.JSON
)
}
JSON reponse
ResponseMsg: [
MSGCODE: 0,
MSGTYPE:S,
MSGINFOR:Hold vehicles completed,
MSGDATA: [
[
KEY:HSP-1099,
VAL: 5,
DESC: DONE
],
[
KEY:HSP-1100,
VAL: 5,
DESC: DONE
],
[
KEY:HSP-1101,
VAL: 5,
DESC: DONE
]
]
]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.