How to read body value from Script Runner Custom API endpoint

serge calderara
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2021

Dear all,

I have the following test custom Rest endpoint in script runner

doSomething(httpMethod: "POST") { MultivaluedMap queryParams, String body ->

>>> How to check for the receive body Json param

return Response.ok().build()
}

When I call that API from POSTMAN, the body which is send is as below :

{

 Job id : "123456"
 PrevSatus : "In queue"
New status : "Completed"

}

How to reads all those Json body param inside my Rest custom API code ?

thanks for help

regards

1 answer

1 accepted

0 votes
Answer accepted
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 2, 2021

Hi @serge calderara ,

for example see here. You need to parse the JSON body:

def form = new JsonSlurper().parseText(body) as Map<String, List>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events