2

This is my first step working with Jira Rest API and I will only return simple serverInfo

Here is my Groovy Script:

def jira = new RESTClient(JIRAURL + "/rest/api/2/");
jira.headers['Content-Type']='application/json'
jira.headers['Authorization']="Basic " + "username:password".bytes.encodeBase64().toString()
println  jira.get(path:'serverInfo')

If I execute my script I get this Exception:

java.lang.NoSuchFieldError: defaultRequestContentType
at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.<init> 
(HTTPBuilder.java:989)

Can anyone help me please?

8bittree
  • 1,769
  • 2
  • 18
  • 25
satko43
  • 21
  • 2

1 Answers1

0

The error "java.lang.NoSuchFieldError" is probably because of

jira.headers[...

Have you tried to set these default headers with methods e.g.

jira.setHeaders([Content-Type: "......"])
jira.setHeaders([Authorization: "Basic ....."])

or

jira.httpClient.defaultHeaders['Content-Type'] = '...' 
jira.httpClient.defaultHeaders['Authorization'] = '...' 

The JIRA Rest call call looks fine and you can test it with Postman to check that issue is not with JIRA itself.

Miroslav Savovski
  • 2,300
  • 2
  • 10
  • 12