signnow / SignNow.NET

SignNow.Net is the official .NET 4.5+ and .NET Standard class library for the SignNow API. SignNow allows you to embed legally-binding e-signatures into your app, CRM or cloud storage. Send documents for signature directly from your website. Invite multiple signers to finalize contracts.
https://www.signnow.com/developers
MIT License
16 stars 12 forks source link

Create document from the template #127

Closed halfdead2296 closed 3 years ago

halfdead2296 commented 3 years ago

When I use create document from template I get followiing error Untitled

### Following is my code public static async Task CreateDocumentFromTheTemplate(string documentName, string templateId, Token token) { // using token from the Authorization step var signNowContext = new SignNowContext(token);

        return await signNowContext.Documents
            .CreateDocumentFromTemplateAsync(documentName, templateId)
            .ConfigureAwait(false);
    }

and I generated token using public static async Task RequestAccessToken(Uri apiBase, CredentialModel clientInfo) { Uri apiBaseUrl =new Uri("https://api-eval.signnow.com");

        string clientId = clientInfo.ClientId;
        string clientSecret = clientInfo.ClientSecret;

        string userLogin = clientInfo.Login;
        string userPassword = clientInfo.Password;

        var oauth = new OAuth2Service(apiBaseUrl, clientId, clientSecret);

        return await oauth.GetTokenAsync(userLogin, userPassword, Scope.All)
            .ConfigureAwait(false);
    }
AlexNDRmac commented 3 years ago

It looks that smth wrong with your credentials. Please double check your clientId, clientSecret and Login/Password.

halfdead2296 commented 3 years ago

I validated Token using following , and it returns true

/// <summary>
    /// Verify access token example
    /// </summary>
    /// <param name="apiBaseUrl">SignNow API base URL. Sandbox: "https://api-eval.signnow.com", Production: "https://api.signnow.com"</param>
    /// <param name="clientInfo"><see cref="CredentialModel"/> with Application Client ID and Client Secret</param>
    /// <param name="token">Access token</param>
    /// <returns></returns>
    public static async Task<bool> VerifyAccessToken(Uri apiBaseUrl, CredentialModel clientInfo, Token token)
    {
        var oauth2 = new OAuth2Service(apiBaseUrl, clientInfo.Login, clientInfo.Password);

        return await oauth2.ValidateTokenAsync(token)
            .ConfigureAwait(false);
    }
halfdead2296 commented 3 years ago

and to note on ds .CreateDocumentFromTemplateAsync(documentName, templateId) .ConfigureAwait(false);

        here in your document order of prameter mismatches with the CreateDocumentFromTemplateAsync function defination
AlexNDRmac commented 3 years ago

and to note on ds .CreateDocumentFromTemplateAsync(documentName, templateId) .ConfigureAwait(false);

        here in your document order of prameter mismatches with the CreateDocumentFromTemplateAsync function defination

Thanks, I''l fix it in next version

Did you try to use SingnNow.Net.Examples solution? Using these examples - all should works.

halfdead2296 commented 3 years ago

Yes thankyou for the fix, closing the issue