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.
I 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