Reputation: 149
Have Groovy script class Using RestClient todownload the csv file, but on executing getting response as webpage.
Please suggest on to download the csv from the link. Putting the link directly in browser downloads the csv file
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.BINARY
import groovyx.net.http.RESTClient
import java.nio.file.Files
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
import java.io.*
class RestCheck {
static void main(def args) {
def sUserName = 'tqqq'
def sPassword = 'qww'
def client = new RESTClient('https:test.com')
def path = "/changedata"
client.setProxy('proxy.help.org' , 8080,'http')
client.auth.basic sUserName, sPassword
try {
def responData = client.get(path: path,contentType:groovyx.net.http.ContentType.ANY)
println responData
} catch(Exception e) {
e.printStackTrace()
}
}
}
Upvotes: 0
Views: 288