'Problem with sending Get request from jenkins pipeline job from Jenkins slave

I am using HTTP-request in Jenkins pipeline job to send Get request from Jenkins slave, the response code is 200, response content is null, but if I send the request from Jenkins master, I can get response content correctly, how can I solve this problem? below is the command I used HTTP-request in Jenkins pipeline

httpRequest acceptType: 'APPLICATION_JSON',
   authentication:  env.MY_CREDENTIAL, 
   contentType: 'APPLICATION_JSON',      
   url:  env.MyURI, 
   wrapAsMultipart: false


Solution 1:[1]

I see nothing wrong with your request but as you commented, looks like the response is string?

You can add consoleLogResponseBody to see how the response looks like.

def response = httpRequest(
    authentication:  env.MY_CREDENTIAL, 
    consoleLogResponseBody: true,
    url:  env.MyURI, 
    wrapAsMultipart: false
)

And you should be able to parse it simply like this

def json = readJSON(text: response.content)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ted