Scheduler not working in production

I have been trying to create a scheduler and it works likes a charm in the local environment. But this fails with an 500 internal error. What am i doing wrong?

 //create a new scheduler.
     $schedule.create({
      name: "leadSyncSchedule100",
      data: {task_id: 10001},
      schedule_at: dateOnly,
      repeat: {
        time_unit: "minutes",
        frequency: 5
      }
    })
    .then(function(data) {
        //"data" is a json with status and message.
        console.log('successfully created'+JSON.stringify(data))
        renderData();
    }, function(err) {
        //"err" is a json with status and message.
        console.log('failure'+JSON.stringify(err))
        renderData();
    });

Hi @gokulets,

Welcome to the forum :wave: ! Can you share the err object / error message associated with the 500 status code that you mentioned ? This should ideally be visible in the browser console logs or in the network log response

I don’t see the error in browser logs but in the app logs section, here is what it says,

failure{“status”:500,“message”:“Internal Server Error”}

Just wondering, if I am hitting any rate limits since i have been testing by trying to run every minute in the production.

Thanks for sharing the code. It seems like you have referenced dateOnly variable during schedule creation. However, this doesn’t seem to be defined anywhere. Can you ensure that the scheduled_at property is a string and is of this format (ISO string) -> 2020-03-13T11:14:35.646Z so that the schedule can be created successfully?

Also, I observe that the code block prior to L746 may not be commented out properly :thinking: The closing curly brace seems to be missed out on L744. Could you kindly check it :slight_smile:

Here is the reference to the doc: https://developers.freshsales.io/docs/scheduled-events/