我正在尝试遵循简单的Aditi Scheduler教程但我收到错误。这是我的代码。
我做错了什么?
错误:输入不是有效的Base-64字符串,因为它包含a 非基础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));
}
}
答案 0 :(得分:0)
问题可能是您传递给WebHookBuilder的网址中的“localhost”?
答案 1 :(得分:0)
这已经有几个月了,但是我遇到了同样的问题,直到我意识到我已经将tenantId和secretKey颠倒了(愚蠢,但很容易出错)。一旦我交换它们就可以了。