Hangfire.HttpJob icon indicating copy to clipboard operation
Hangfire.HttpJob copied to clipboard

使用 Hangfire.HttpJob.Client 代码方式添加周期作业,未能成功

Open dodu2014 opened this issue 10 months ago • 0 comments

参考内容:https://github.com/yuzd/Hangfire.HttpJob/wiki/05.%E9%99%A4%E4%BA%86%E6%89%8B%E5%8A%A8%E6%B7%BB%E5%8A%A0job%E8%BF%98%E5%8F%AF%E4%BB%A5%E5%86%99%E4%BB%A3%E7%A0%81%E6%B7%BB%E5%8A%A0

代码:

  [HttpGet]
  public async Task<IActionResult> TestAddRecurringJobAsync() {
    var result = await HangfireJobClient.AddRecurringJobAsync(
      "http://localhost:3108/dashboard", // 这是正确的,我在program中配置的地址
      new RecurringJob() {
        JobName = "测试5点40执行",
        Method = "Post",
        Url = "http://localhost:3108/test/value2",
        Mail = ["[email protected]"],
        Cron = "40 17 * * *",
      },
      new HangfireServerPostOption { BasicUserName = "***", BasicPassword = "******" }
    );

    return Ok(result);
  }

其中用户名和密码我隐藏了

返回消息:

{"errMessage":"Forbidden","isSuccess":false}

dodu2014 avatar May 02 '25 15:05 dodu2014