# When I insert an if block into the ScheduledTask, I'm entering the password and the program is closing

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[
"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}]]

• Did you try just If[URLRead... to see how your condition works? Also === would be more appropriate, and even more MatchQ[ KeyValuePattern["StatusCode"->_] ].
– Kuba
Dec 30, 2020 at 12:24
• Yes I have already tried and it's working. Could the problem be on the schedule? Dec 30, 2020 at 14:22
• 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... Dec 30, 2020 at 16:12