I've created a very simple API that imports the "Plaintext" of a URL or a PDF. Here is my code:
urlScraperTest = APIFunction[
{"url" -> "String"},
Import[#url, "Plaintext"] &];
and deployed it to the Wolfram Cloud:
CloudDeploy[urlScraperTest, "urlScraper", Permissions -> "Public", CloudObjectNameFormat -> "CloudUserUUID"]
CloudObject["https://www.wolframcloud.com/obj/user-7d8eeec4-69a3-4149-bc75-10de306a3cbd/urlScraper"]
This code works fine if I pass it some URLs, e.g. here is a recipe that I am able to scrape from my browser:
https://www.wolframcloud.com/obj/user-7d8eeec4-69a3-4149-bc75-10de306a3cbd/urlScraper?url=https://www.foodandwine.com/recipes/beef-wellington
But when I try to pass the code a PDF file name, it produces an (unhelpful) "$Failed" error. For instance, here is a simple pdf stored in a cloud location:
https://bbf184a8c110ea5f6bb4192bc1d23ad5.cdn.bubble.io/f1703793538605x556426251682794500/Perfect%20Chocolate%20Chip%20Cookies%20Recipe%20-%20NYT%20Cooking.pdf
If I enter this location in my browser search bar directly, the PDF renders correctly. But if I try to pass this URL to my function
https://www.wolframcloud.com/obj/user-7d8eeec4-69a3-4149-bc75-10de306a3cbd/urlScraper?url=https://bbf184a8c110ea5f6bb4192bc1d23ad5.cdn.bubble.io/f1703793538605x556426251682794500/Perfect%20Chocolate%20Chip%20Cookies%20Recipe%20-%20NYT%20Cooking.pdf
It produces a "$Failed" message. Note: If I call the URLScraperTest[] function directly from a local MMA notebook using the above URL, it does return the results I expect with no error.
Can someone help shed some light on this behavior and suggest a solution?
Thanks!