【发布时间】:2019-08-31 18:49:06
【问题描述】:
我想为AYLIEN text analytics API 的 GET 请求/API 调用提供参数。我可以将密钥和 ID 的标头设置为授权,并且调用本身可以工作(运行代码后我的 API 使用统计增加),但我不知道如何提供要分析的文本作为参数。
def customScript(){
def connection = new
URL("https://api.aylien.com/api/v1/sentiment").openConnection() as
HttpURLConnection
connection.requestMethod = 'GET'
// set headers
connection.setRequestProperty('X-AYLIEN-TextAPI-Application-Key','//mykey')
connection.setRequestProperty('X-AYLIEN-TextAPI-Application-ID', '//myid')
// get the response code - automatically sends the request
println connection.responseCode + ": " + connection.inputStream.text
}
【问题讨论】:
标签: groovy httprequest get-request