Hi
I am attempting to POST data from a Groovy Script to an external REST API. The external API requires the data to be in the format:
http://someSite/someAPI/SomeAction?AuthToken=S_AUTH_TOKEN&domainName=aS_DOMAIN&PRODUCT_NAME=S_PRODUCT_NAME&input Data=[{"RequestAction":"S_RA", "Subject":"A Subject","accounts":[{"name":"John Doe","firstName":"John","lastName":"Doe" },{"name":"Jane Doe","firstName":"Jane","lastName":"Doe" }]}]
In order to achieve this, I am using an HTTPBuilder:
def baseURL = "http://someSite/someAPI";
def baseAction = "/SomeAction";
def httpBuilderRequest = new HTTPBuilder(baseURL + baseAction);
httpBuilderRequest.request(POST) {
requestContentType = ContentType.JSON
body = [AuthToken: "S_AUTH_TOKEN"
, PRODUCT_NAME: "S_PRODUCT_NAME"
, domainName: "S_DOMAIN"
, inputData:
[{RequestAction:"S_RA", "Subject":"Some Subject", accounts: [{"name":"John Doe","firstName":"John","lastName":"Doe" }]}]
]
response.success = {resp, JSON ->
}
response.failure = {resp, JSON ->
}
}
The "accounts" data is derived from a Jira issue obtained earlier, but that is not the issue. I have tried:
- Sending a string URL with the data as pre-formatted query string without a body (this works successfully in PostMan). This attempt returns an Illegal character in query error pointing to the first instance of a square bracket
- Building the body as above. This does not work as Groovy is not happy with the formatting of the nested objects (See images below)
- Using a JsonSlurper to parse the data. This simply replaces all the braces {} with square brackets and the external API cannot read valid Json


Is there perhaps anyone who could assist with a solution to this problem (Jira Server 8.19.9 is being used)
Thank you in advance