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:
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