R:Httr包 - 与API连接,错误1200:描述“:”__ all__:需要img或url参数

问题描述 投票:0回答:1

我是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."

如何在代码中实现图像或URL地址以获得API分析?

r api httr
1个回答
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)
© www.soinside.com 2019 - 2024. All rights reserved.