Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

adding authorization in groovy request

Jamshaid
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.
September 22, 2020

I am trying to run a post request using ScriptRunner which sends a post request to an API. Here is the code I have tried using a dummy API.

def postmanPost = new URL("https://jamshaid.free.beeceptor.com/test")
def postConnection = postmanPost.openConnection()

def form = "param1:This is request parameter."
postConnection.doOutput = true
def text="mm"
postConnection.with {
outputStream.withWriter { outputStreamWriter ->
outputStreamWriter << form
}
text = content.text
}
assert postConnection.responseCode == 200

 

I have got this code from here. 

It responds to a POST request and here are my configurations about the request.

123.pngI am trying to add authorization to the request but the method given there doesn't work. Is there any way I could add authorization to my current code?
Thanks a lot

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events