Restb.ai Watermark Detection

פרמיום
על ידי Restb.ai | מְעוּדכָּן לפני שנה | Visual Recognition
פּוֹפּוּלָרִיוּת

9.2 / 10

חֶבִיוֹן

1,010ms

רמת שירות

100%

חזרה לכל הדיונים

Forbidden 403 error when making POST calls from R

avatar
anthonypileggi
לפני שנתיים

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:

httr::POST(
  url = "https://rapidapi.com/restb/api/restb-ai-watermark-detection",
  config = httr::add_headers(
    `X-RapidAPI-Host` = "restb-ai-watermark-detection.p.rapidapi.com",
    `X-RapidAPI-Key` = Sys.getenv("RAPIDAPI_KEY"),
    `Content-Type` = "application/x-www-form-urlencoded"
  ),
  #query = list("rapidapi-key" = Sys.getenv("RAPIDAPI_KEY")),
  #httr::content_type("form"),
  body = list(image_url = "https://storage.googleapis.com/pbm-product-photos/03091_2.jpg")
  #encode = "form"
)

And the 403 response I keep getting:

Response [https://rapidapi.com/restb/api/restb-ai-watermark-detection?rapidapi-key={my_api_key}&image_url=https%3A%2F%2Fstorage.googleapis.com%2Fpbm-product-photos%2F03091_2.jpg]
  Date: 2020-06-25 21:28
  Status: 403
  Content-Type: text/html; charset=utf-8
  Size: 136 B
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Forbidden</pre>
</body>
</html>

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

avatar
anthonypileggi commented לפני שנתיים

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

avatar
restb commented לפני שנתיים

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 https://restb-ai-watermark-detection.p.rapidapi.com/wmdetect.

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

httr::POST(
  url = "https://restb-ai-watermark-detection.p.rapidapi.com/wmdetect",
  httr::add_headers(
    X-RapidAPI-Host = "restb-ai-watermark-detection.p.rapidapi.com",
    X-RapidAPI-Key = Sys.getenv("RAPIDAPI_KEY"),
    Content-Type = "application/x-www-form-urlencoded"
  ),
  body = list(image_url = "https://storage.googleapis.com/pbm-product-photos/03091_2.jpg"),
  encode = "form"
)

I hope this would help with your integration.

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות
דירוג: 5 - הצבעות: 1