HTTP post request from REST Endpoint

Oleksii Okhmush September 21, 2022

I try to build REST endpoint with POST method.
In this endpoint after some logic i need to send http POST request

if i do this block of code from Script Console it works fine, but if this block runs from REST Endpoint, i see that request body is empty.

 

import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method

def http = new HTTPBuilder('URL')
http.request(Method.POST) {
requestContentType = ContentType.JSON
headers."Authorization" = "Bearer "


body ="""

HI

"""


response.success =

{ resp, JSON -> log.warn("POST success "+JSON) }

response.failure =

{ resp, JSON -> log.warn("POST fail "+JSON) }

}

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2022

Hi @Oleksii Okhmush

Could you please provide a little bit more information, i.e. what are you trying to do with the REST Endpoint? Do you want to update the value of a particular field?

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer