我正在尝试使用DicuSign(V 4.0.0-rc)的C#SDK执行分块上传。我正在使用以下代码:
var config = new Configuration(new ApiClient("https://demo.docusign.net/restapi"));
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(config);
ChunkedUploadResponse createResponse = envelopesApi.CreateChunkedUpload(accountId);
byte[] buffer = new byte[5 * 1024 * 1024];
int bytesRead;
string path = "Sample 30 Mb File.pdf";
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
int sequence = 1;
while ((bytesRead = fileStream.Read(buffer, 0, MAX_BUFFER)) > 0)
{
string base64Chunk = Convert.ToBase64String(buffer);
var updatePartResponse = envelopesApi.UpdateChunkedUploadPart(accountId,
createResponse.ChunkedUploadId, sequence.ToString(),
new ChunkedUploadRequest() { Data = base64Chunk });
sequence++;
}
}
var updateResponse = envelopesApi.UpdateChunkedUpload(accountId,
createResponse.ChunkedUploadId);
但是,SDK会在CreateChunkedUpload()中代码上方的第四行中引发异常:
DocuSign.eSign.Client.ApiException:'调用CreateChunkedUpload时出错:{“ errorCode”:“ INVALID_CONTENT_TYPE”,“ message”:“不支持指定的内容类型。主体的Content-Type必须为application / json或application / xml“}'
然后我在配置中的标题下方添加了代码(在上述代码的第三行):
config.AddDefaultHeader("Content-Type", "application/json");
现在我得到了例外:
DocuSign.eSign.Client.ApiException:'调用CreateChunkedUpload时出错:{“ errorCode”:“ UNSPECIFIED_ERROR”,“ message”:“非静态方法需要目标。”}'
我在发送请求时缺少任何内容吗?如何解决此错误,或者是否有其他替代方法可以使用SDK进行分块上传?