3
$\begingroup$

I'd like to see a single example of APIFunction deployed that is accessible via curl, not a web browser.

For example:

func = APIFunction[{"x" -> "Integer"}, FactorInteger[#x] &];
URLFetch["https://www.wolframcloud.com/objects/66b35b10-0f8e-4be4-bbdc-7ee3f6fbf82a", "Parameters" -> {"x" -> "1"}]

gives

enter image description here

Api's are not generally meant to be used by logging in and manipulating elements in a web page. I"m sure this is possible and I'm just missing something.

$\endgroup$
1
  • $\begingroup$ You have to make the API public, if it's not public then it redirects you to a login form because when you send the request with cURL/URLFetch like that it cannot know who you are. That HTML is probably for the login form. $\endgroup$
    – C. E.
    Commented Feb 18, 2016 at 21:35

1 Answer 1

2
$\begingroup$

Deploy your API with public permissions or add Username and Password options to URLFetch:

With[{cloudobject = FileNameJoin[{$CloudRootDirectory, "FactorIntegerAPI"}]}, 
   CloudDeploy[
      APIFunction[{"x" -> "Integer"}, FactorInteger[#x] &],
      cloudobject, Permissions -> "Public"]; 
   URLFetch[URLBuild[cloudobject, {"x" -> "1"}]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.