Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Mar 06, 2018 @ 19:20
    Michaël Vanbrabandt
    0

    Scheduled Task is not working

    Hi all,

    having some issues with the ScheduledTasks from the umbracoSettings.config file.

    The following line is added using IPackageAction:

    <task log="true" alias="memberUnlock" interval="60" url="http://localhost:61214/umbraco/backoffice/memberunlock/memberunlockapi/dounlock" />
    

    But the method is never called, manually going to this url works perfectly.

    I can see the following in the log file:

     2018-03-06 20:10:21,824 [P20204/D2/T41] INFO  Umbraco.Web.Scheduling.ScheduledTasks - memberUnlock has been called with response: False
     2018-03-06 20:11:21,861 [P20204/D2/T47] INFO  Umbraco.Web.Scheduling.ScheduledTasks - memberUnlock has been called with response: False
     2018-03-06 20:12:21,885 [P20204/D2/T48] INFO  Umbraco.Web.Scheduling.ScheduledTasks - memberUnlock has been called with response: False
    

    Api controller:

    namespace MemberUnlock.Controllers
    {
        /// <summary>
        /// Implement the MemberUnlockApiController
        /// </summary>
        [PluginController("MemberUnlock")]
        public class MemberUnlockApiController : UmbracoAuthorizedApiController
        {
            /// <summary>
            /// Ctor
            /// </summary>
            public MemberUnlockApiController() { }
    
            [HttpGet]
            public void DoUnlock()
            {
                // Code...
            }
        }
    }
    

    Any ideas?

    /Michaël

  • Pawel Bres 39 posts 160 karma points c-trib
    Mar 06, 2018 @ 21:27
    Pawel Bres
    100

    it's because it's Authorized Controller, your scheduled task is not Authorized :)

    I don't think there is an option to make it work with authorized controller because of security reasons.

    What I usually do it such cases is adding ApiKey (e.g. Guid) in web.config and then pass the same key in scheduled task url and check it inside the action.

Please Sign in or register to post replies

Write your reply to:

Draft