6
$\begingroup$

It seems that sources of URL* related features are not initialized properly which leads to problems in many cases.

Please follow those steps to reproduce the problem:

  • Let's deploy a test api:

    api = First @ CloudDeploy @ Delayed @ HTTPErrorResponse[404]
    
  • Check:

    URLRead[api]
    

    enter image description here

    So far so good

  • Copy api url string and try

      URLRead["https://www.wolframcloud.com/objects/...."]
    

    Should return 404, nothing unexpected.

  • Now Quit[] the Kernel and run the manual check again:

      URLRead["https://www.wolframcloud.com/objects/...."]    
    

    enter image description here

What?

What is more interesting, deploy another api and run manual test for the old url, now it works again...

How to classify this feature? What to call to have stuff initialized/loaded properly?

[CASE:3855442] was created

$\endgroup$

1 Answer 1

4
$\begingroup$

Quick explanation: Thanks to WRI Support reply we can understand why this happens:

  • the cloud object has default private privileges

  • so in new session URLRead will be redirected to cloud login page, correctly returning 200

Further doubts: This makes things clearer but I still believe the behavior isn't entirely consistent. Here is why:

  • I have cloud credentials cached by 'Remember Me' checkbox

  • Calling cloud object specified by plain url string works, once we are logged in, and does not require any addition to URLRead in order to resolve the authorization

So I'd expect it to always work or to have 'Remember Me' well documented. E.g. when exactly credentials are restored in a new session.

WRI Support agrees:

[..] I understand the way that Mathematica handles the saved Wolfram Cloud credentials is complex and needs further clarification. I have forwarded your suggestion to the appropriate people in our development group. [...]

What to do to not face the issue?

Using CloudObject as a wrapper for cloud links reminds Mathematica that credentials are needed and it will work even after Quit[].

api = First @ CloudDeploy @ Delayed @ HTTPErrorResponse[404]
 "https://www.wolframcloud.com/objects/..."

Quit[];

URLRead["https://www.wolframcloud.com/objects/..."]

(*200*)

URLRead[CloudObject @ "https://www.wolframcloud.com/objects/..."]

(*404*)
$\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.