我有以下代码:
curl -v -X PUT -H "X-IBM-Client-Id:YOUR_CLIENT_ID" -H "X-IBM-Client-Secret:YOUR_CLIENT_SECRET" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type:text/csv" https://api.ibm.com/watsonanalytics/run/data/v1/datasets/ID_OF_DATA_SET/content -d "YOUR_DATA"
该代码是他们为了上传数据而给我的示例,当我尝试将其翻译为R时,它看起来像这样: 我使用以下库: 库(RCurl) 库(RJSONIO) 库(XML) 库(HTTR) 库(readr)
代码如下:
Upload_data<-PUT( url = "https://api.ibm.com/watsonanalytics/run/data/v1/datasets/DataID/content",
add_headers('Content-Type' = 'text/csv'),
add_headers('Accept'= 'application/json'),
add_headers('X-IBM-Client-Secret' = Secret),
add_headers('X-IBM-Client-Id' = Client),
add_headers('Authorization: Bearer'=Auth, body= "Province,Population density,Area,Population,
Ontario,97,83858,8169929
Quebec,337,30510,11007020
Alberta,111,547030,63601002
Manitoba,233,357021,81799600
British Columbia,393,41526,16824400
Costa Rica, 1,10000, 1000000"))
似乎它不起作用,你知道某种方法来解决它吗?
答案 0 :(得分:0)
如果我没弄错,我相信Watson Analytics API Explorer尚不支持R,这是您的PUT请求正在使用“https://api.ibm.com/watsonanalytics/”
支持的语言包括Python,JavaScript,Java,C#和PHP。