How to curl an xml in groovy?

I'm currently trying to curl an xml file through groovy:

def command = "curl -H \"Accept:  application/xml\" ${path}" 
def process = command.execute() 

When I try to execute this script, the output has no xml formatting (as in, there are no xml tags, just the contents) and I also get

curl: (6) Could not resolve host: application; Name or service not known

I tried running the same command directly in the terminal and it works fine there.


  • Replace:

    def command = "curl -H \"Accept:  application/xml\" ${path}" 


    def command = ['curl', '-H', 'Accept:  application/xml', path]