What is the syntax for a Groovy HTTP Request

Ernest Phillips October 26, 2018

I am attempting to use ScriptRunner to make a REST api call. 

However, I am not certain that I have the syntax correct or where I can test to see if I am getting the data I am looking for.

 

This is the script I am working with :

 

import groovyx.net.http.*
import groovyx.net.http.ContentType.*
import groovyx.net.http.Method.*
import net.sf.json.*


def http = new HTTPBuilder('https://api.somewebsite.com')
http.get( path : '/MyPath/GoesHere/',
contentType : JSON,
query : [
token: 'MyToken',
license:'ABC123'] )
{ resp, reader -> println "response status: ${resp}"
println 'Response data: -----' }

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events