开发者社区> 问答> 正文

使用钉钉后端C#版本版本SDK创建待办失败

调用后返回错误信息:

code: 404, 
Specified api is not found, please check your url and method. 
request id: 09FC4369-0D9D-71C3-962E-341248F56420

不知道是何原因,请帮忙看下,谢谢!

C#完整代码如下:

public static CreateTodoTaskResponseBody CreateDingTalkTodo(string creatorId, string appUrl, string pcUrl, string sourceId, string subject, string description, int dueTime
    , string executorIds, string participantIds, bool isOnlyShowExecutor, int priority)
{
    AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
    config.Protocol = "https";
    AlibabaCloud.SDK.Dingtalktodo_1_0.Client client = new AlibabaCloud.SDK.Dingtalktodo_1_0.Client(config);

    CreateTodoTaskHeaders createTodoTaskHeaders = new CreateTodoTaskHeaders();
    createTodoTaskHeaders.XAcsDingtalkAccessToken = GetToken();
    CreateTodoTaskRequest.CreateTodoTaskRequestActionList.CreateTodoTaskRequestActionListParam actionList0Param = new CreateTodoTaskRequest.CreateTodoTaskRequestActionList.CreateTodoTaskRequestActionListParam();

    CreateTodoTaskRequest.CreateTodoTaskRequestActionList actionList0 = new CreateTodoTaskRequest.CreateTodoTaskRequestActionList
    {
        Param = actionList0Param,
    };
    CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs notifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs
    {
        DingNotify = "1",
    };
    CreateTodoTaskRequest.CreateTodoTaskRequestContentFieldList contentFieldList0 = new CreateTodoTaskRequest.CreateTodoTaskRequestContentFieldList();
    CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl detailUrl = new CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl
    {
        AppUrl = appUrl,
        PcUrl = pcUrl,
    };
    CreateTodoTaskRequest createTodoTaskRequest = new CreateTodoTaskRequest
    {
        OperatorId = creatorId,
        SourceId = sourceId,
        Subject = subject,
        CreatorId = creatorId,
        Description = description,
        DueTime = dueTime,
        ExecutorIds = executorIds?.Split(',').ToList<string>(),
        ParticipantIds = participantIds?.Split(',').ToList<string>(),
        DetailUrl = detailUrl,
        ContentFieldList = new List<CreateTodoTaskRequest.CreateTodoTaskRequestContentFieldList>
        {
            contentFieldList0
        },
        IsOnlyShowExecutor = isOnlyShowExecutor,
        Priority = priority,
        NotifyConfigs = notifyConfigs,
        BizCategoryId = "123",
        ActionList = new List<CreateTodoTaskRequest.CreateTodoTaskRequestActionList>
        {
            actionList0
        },
    };

    try
    {
        CreateTodoTaskResponse res = client.CreateTodoTaskWithOptions(creatorId, createTodoTaskRequest, createTodoTaskHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
        return res.Body;
    }
    catch (TeaException err)
    {
        if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
        {
            Logger.Error(err.Message);
            throw new Exception(err.Message);
        }
    }
    catch (Exception _err)
    {
        TeaException err = new TeaException(new Dictionary<string, object>
        {
            { "message", _err.Message }
        });
        if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
        {
            Logger.Error(err.Message);
            throw new Exception(err.Message);
        }
    }
    return null;
}

展开
收起
游客g2hoztwnwhiyy 2024-09-05 13:10:47 40 0
3 条回答
写回答
取消 提交回答
  • 这个人很懒....什么都没写。

    可以考虑自己写一个SDK

    2024-09-11 11:02:36
    赞同 38 展开评论 打赏
  • API 找不到。

    InvalidApi.NotFound

    Specified api is not found, please check your url and method.

    404

    请检查指定的 action 接口名称是否正确,注意大小写区分。

    image.png

    HttpCode为4xx,调用全阿里云产品的OpenAPI均可能遇到,表示业务错误。一般为请求格式错误、请求方式错误、必填参数丢失、参数格式错误、签名错误、流控限制等问题。此时需查看具体错误码,针对性解决问题。

    参考文档https://help.aliyun.com/zh/api-gateway/traditional-api-gateway/support/error-codes

    2024-09-06 09:39:28
    赞同 45 展开评论 打赏
  • 北京阿里云ACE会长

    确保您使用的API地址是正确的,没有拼写错误或路径错误。请对照钉钉开放平台文档中关于创建待办事项API的最新地址进行核对
    image.png

    2024-09-05 13:27:34
    赞同 36 展开评论 打赏
来源圈子
更多
收录在圈子:
+ 订阅
问答排行榜
最热
最新

相关电子书

更多
十分钟上线-使用函数计算构建支付宝小程序服务 立即下载
钉钉小程序——为工作方式插上翅膀 立即下载
机器学习在互联网后端技术中的应用 立即下载