0
$\begingroup$

I'm new in Mathematica. So I'm unable to settle a matter. When I insert an if block into the ScheduledTask, I'm entering the password and the program is closing. What is my mistake? Can you help me please?

obj = SessionSubmit[
       ScheduledTask[
      If[URLRead[
     "https://api.archis.company/welcome", {"StatusCode", 
     "Body"}] == 
     <|"StatusCode" -> 200, "Body" -> "\"Welcome To ArchisAcademy API!\""|>, 
      SendMail["wlmailtest@wolfram.com", 
      "Here is the body of the message."]],
      {Quantity[1, "Seconds"], 30}]]
$\endgroup$
8
  • $\begingroup$ Did you try just If[URLRead... to see how your condition works? Also === would be more appropriate, and even more MatchQ[ KeyValuePattern["StatusCode"->_] ]. $\endgroup$ – Kuba Dec 30 '20 at 12:24
  • $\begingroup$ Yes I have already tried and it's working. Could the problem be on the schedule? $\endgroup$ – seher Dec 30 '20 at 14:22
  • $\begingroup$ Why and where are you entering a password? Is a password dialog popping up when the scheduled task runs? Is that for the email? If so, I think you will need to eliminate the need of that interactive password dialog, I am quite sure that this will create problems within the scheduled task... $\endgroup$ – Albert Retey Dec 30 '20 at 16:12
  • $\begingroup$ It's email's password for authentication. So how can I log in without opening the password dialog? $\endgroup$ – seher Dec 30 '20 at 17:23
  • $\begingroup$ How come it shows you the dialog, I am getting "AuthenticationDialog is not currently supported within preemptive evaluations." - message. Which can be worked around with: mathematica.stackexchange.com/a/206416/5478 $\endgroup$ – Kuba Dec 31 '20 at 7:38

Your Answer

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

Browse other questions tagged or ask your own question.