-1

我正在尝试遵循简单的 Aditi Scheduler 教程,但出现错误。这是我的代码。

我究竟做错了什么?

错误:输入不是有效的 Base-64 字符串,因为它包含非 base 64 字符、两个以上的填充字符或填充字符中的非法字符。

[TestMethod]
public void ScheduledSMS()
{

    var tenantId = "xxxxxxxxxxxmyid";
    var secretKey = "xxxxxxxxxxxmykey";


    var scheduledTasks = new ScheduledTasks(tenantId, secretKey);

    // create a task
    var task = new TaskModel
    {
        Name = "My first Scheduler job",
        JobType = JobType.Webhook,

        // use predefined CommonCronExpressions or build your own CRON expressions here http://cronmaker.com/
        CronExpression = CommonCronExpressions.EveryMinute,

        // use builders to set job properties for webhooks and azure queue 
        Params = ParamBuilderFactory
                    .WebHookBuilder("http://localhost:1901/SMS/SendText")
                    .Build()
    };

    var operationId = scheduledTasks.CreateTask(task);   <------ Error happens here..

    // all operations in the api follow fire and forget approach, once an operation like create/update/delete
    // is requested it returns an operationId(Guid) which can be used to fetch the operation status

    // operation status can be fetched in two ways:

    // method 1: (without polling) returns the status without polling
    var operationStatus = scheduledTasks.GetOperationStatus(operationId);

    // method 2: (with polling) polls until the operation status changes to success/error or a timeout occurs 
    // var operationStatus = scheduledTasks.GetOperationStatus(operationId, true);

    // get the task
    TaskModel newTask = null;
    if (operationStatus.Status == StatusCode.Success)
    {
        dynamic resultData = operationStatus.Data;
        var newTaskId = resultData["Id"];
        newTask = scheduledTasks.GetTask(Guid.Parse(newTaskId));
    }


}
4

2 回答 2

0

也许问题出在您传递给 WebHookBuilder 的 url 中的“localhost”?

于 2013-10-16T13:17:20.480 回答
0

这已经有几个月大了,但是我遇到了同样的问题,直到我意识到我的tenantId 和secretKey 颠倒了(愚蠢,但容易出错)。一旦我交换了它们,它就可以正常工作。

于 2014-01-22T01:28:04.450 回答