9
$\begingroup$

I created an API function that given an integer, would return the factors of that integer.

func=APIFunction[{"x"->"Integer"},FactorInteger[#x]&];
api=CloudDeploy[func]

This returns a URL which I can now append my query string to and submit for an answer.

Hyperlink[First[api]<>"?x=2434500"]

Instead of making this function call in Mathematica, I would like to call this function in a standalone application (using LiveCode). When I attempt this, my application requests the info from the URL, but it returns nothing. I believe this may be because there are credentials that I must provide to the Wolfram Cloud so it knows it is me. However, I do not know how to do this. Does anyone have experience making API calls to Wolfram Cloud (without using the EmbedCode[] function)? How do I go about authenticating with Wolfram Cloud? Are there other things that must be done by my application before this would work?

I also tested this by making an API that was Public like so:

func=APIFunction[{"x"->"Integer"},FactorInteger[#x]&];
api=CloudDeploy[func,Permissions->"Public"]

This also did not work.

$\endgroup$
  • $\begingroup$ When you access the URL in LiveCode, does the result contain any useful diagnostic information? $\endgroup$ – WReach Oct 23 '14 at 20:31
  • $\begingroup$ Unfortunately not, I also tried to specify the format as "Text" in the event that mattered, but to no avail. $\endgroup$ – tjm167us Oct 23 '14 at 21:19
  • $\begingroup$ CloudDeploy in V10 front end authenticates using WolframID popup. Don't know about programmatically, isn't it an Option? $\endgroup$ – alancalvitti Oct 24 '14 at 14:53
  • $\begingroup$ Changed the title to make more general. Since I am having the same problem with "Public" as well, I feel like there is something that I missing to make the RESTful API work. $\endgroup$ – tjm167us Oct 24 '14 at 17:18
2
$\begingroup$

If you've made the API public, you should not need to authenticate. You can validate this by opening the URL in a different browser that does not have an OAuth session with any wolfram sites. You may be running into XSS issues, which may require that you use CORS or similar. I'm not familiar with LiveCode, but you might look into how it handles XSS issues.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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