首页 > 解决方案 > 文档 | 为什么 API 返回“资源不支持 http 方法 'POST'” | C#

问题描述

我正在尝试将文件上传到 springCM 并收到此消息:

“请求的资源不支持 http 方法 'POST'。”

命中端点:

....springcm.com/v201411/folders/{folderGUID}/documents

与他们的文档相匹配: 在此处输入图像描述

该名称是可选的,但我尝试在 URL 中将其作为参数传递。

这是我认为相关的代码:

Uri uri = new Uri("https://....springcm.com/v201411/folders/32dsdfdb-9356-eb11-b875-45df378sdfds/documents");
                
Stream uploadFile = File.OpenRead(filePath + fileName);
HttpContent fileStreamContent = new StreamContent(uploadFile);
using (client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
    formData.Add(fileStreamContent);
    var response = await client.PostAsync(uri, formData);
    if (!response.IsSuccessStatusCode)
    {
        Console.WriteLine(response.Content.ReadAsStringAsync().Result);
    }
    await response.Content.ReadAsStreamAsync();
}

我在这里做错了什么?蒂亚!

标签: c#restdocusignapi

解决方案


您需要使用正确的子域,该子域应以apiupload. 完整的 URL 应如下所示:

https://apiupload[datacenter].springcm.com/[api version]/folders/[folder identifier]/documents{?name}

更多信息:https ://developers.docusign.com/docs/clm-api/clm101/content-api/


推荐阅读