这是我用来将草稿信封发送给签名处理程序的完整流程,以便签名处理程序可以在发送给其他签名者收件人之前进行修改:
//获取访问令牌:
private void GetAccessToken()
{
var apiClient = new ApiClient();
string ik = integrationKey;
string userId = userId;
string authServer = authServer;
string fileContents = await FileHelper.ReadFileContentAsString(RSAKeyPemFile);
//Request for access token
OAuth.OAuthToken authToken = apiClient.RequestJWTUserToken(ik,
userId,
authServer,
Encoding.UTF8.GetBytes(fileContents),
1);
//Get userinfo for AccountId and BaseURI
string accessToken = authToken.access_token;
apiClient.SetOAuthBasePath(authServer);
OAuth.UserInfo userInfo = apiClient.GetUserInfo(authToken.access_token);
Account acct = null;
var accounts = userInfo.Accounts;
{
acct = accounts.FirstOrDefault(a => a.IsDefault == "true");
}
string accountId = acct.AccountId;
string baseUri = acct.BaseUri + "/restapi";
//Set details to configuration object which would be used for sending envelope request
this.accessToken = accessToken;
this.accountId = accountId;
this.baseUri = baseUri;
}
//创建信封
private EnvelopeDefinition MakeEnvelope()
{
// create the envelope definition
EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = "Please sign this document";
//Get document extension
Document documentToSign = new Document
{
DocumentBase64 = Convert.ToBase64String(documentBytes),
Name = documentName,
FileExtension = documentExtension,
DocumentId = documentId
};
// The order in the docs array determines the order in the envelope
env.Documents = new List<Document> { documentToSign };
var routingOrder = 1;
var signatureHandler = new Editor
{
Email = signatureHandler.mail,
Name = signatureHandler.displayName,
RecipientId = routingOrder.ToString(),
RoutingOrder = routingOrder.ToString()
};
routingOrder++;
List<Signer> signers = new List<Signer>();
foreach (var signer in signerList)
{
signers.Add(new Signer { Name = signerList.displayName, Email = signerList.mail, RoleName = signerList.jobTitle, RecipientId = routingOrder.ToString(), RoutingOrder = routingOrder.ToString() });
routingOrder++;
}
// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
Editors = new List<Editor> { signatureHandler },
Signers = signers
};
//Attache all recipients to envelope
env.Recipients = recipients;
env.EventNotification = eventNotification;
env.Status = "created";
return env;
}
//发送草稿信封
public void SendEnvelope()
{
EnvelopeDefinition env = MakeEnvelope();
var config = new Configuration(baseUri);
var apiClient = new ApiClient(baseUri);
apiClient.Configuration = config;
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary result = await envelopesApi.CreateEnvelopeAsync(accountId, env);
}
但是每次在管理员帐户草稿下的草稿信封而不是签名处理程序(在这种情况下是编辑器)。我做错了什么?