R:Httr软件包-与API相连,错误1200:description”:“ __ all__:需要img或url参数

时间:2019-02-19 20:33:31

标签: r api httr

我是HTTR的新手,并且是R与API的连接。我无法与F.A.C.E API(文档:https://face-api.sightcorp.com/dev-documentation/)连接

library(httr)
library("XML")
library("jsonlite")
library(RCurl)

key = 'XXX'
img = 'C:\\my_image.jpg'

The query:
my_json <- POST('https://api-face.sightcorp.com/api/detect/', add_headers(app_key = key, img = img, ethnicity = TRUE ))
print(my_json)

和答案:

Response [https://api-face.sightcorp.com/api/detect/]
  Date: 2019-02-19 20:26
  Status: 200
  Content-Type: application/json
  Size: 88 B
{
  "error_code" : 1200,
  "description" : "__all__ : img or url parameter is needed."

如何在代码中实现img或url地址以获得API分析?

1 个答案:

答案 0 :(得分:0)

解决方案如下:

my_body = list('app_key'=key, 'img'= upload_file(img.url))
my_json <- POST('https://api-face.sightcorp.com/api/detect/',body = my_body)