Watermark Detection

부분 유료
분류별 | 업데이트됨 일 년 전 | Visual Recognition

9.3 / 10

지연 시간


서비스 수준


모든 토론으로 돌아가기

Forbidden 403 error when making POST calls from R


I’m trying to make API calls using the httr package in R, but it keeps returning a 403 error. Is there something obviously wrong with my API call?

R code I am using:

  url = "",
  config = httr::add_headers(
    `X-RapidAPI-Host` = "",
    `X-RapidAPI-Key` = Sys.getenv("RAPIDAPI_KEY"),
    `Content-Type` = "application/x-www-form-urlencoded"
  #query = list("rapidapi-key" = Sys.getenv("RAPIDAPI_KEY")),
  body = list(image_url = "")
  #encode = "form"

And the 403 response I keep getting:

Response [{my_api_key}&]
  Date: 2020-06-25 21:28
  Status: 403
  Content-Type: text/html; charset=utf-8
  Size: 136 B
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">

Any help would be appreciated, I have 50k images I want to run this on ASAP. Thanks!

anthonypileggi commented 2년 전

Awesome, this works perfectly! Thank you very much for the quick response!!

restb commented 2년 전

Hey Anthony,

Looking at your R code it looks like you are sending request headers (rapidapi-key) and body (image_url) as query parameters making not possible for RapidAPI to authenticate your request.

Also, it looks like the URL that you are using is not the correct one. You should use

Taking a look at the getting started website from httr this, or something close to this, should work:

  url = "",
    X-RapidAPI-Host = "",
    X-RapidAPI-Key = Sys.getenv("RAPIDAPI_KEY"),
    Content-Type = "application/x-www-form-urlencoded"
  body = list(image_url = ""),
  encode = "form"

I hope this would help with your integration.

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입
등급: 5 - 투표: 1