You need to sign in to do that
Don't have an account?
Nag22
Error - The remote server returned an error: (401) Unauthorized
Hi,
I am working on integration with docusign.
I have created an Rest Resouce class to update record in salesforce, and I have give this class URL like
https://test.salesforce.com/apexrest/services/UpdateRecord
Now docusign is calling this URL when ever the docusign database updated. But while calling this URL docusign getting
https://cs5.salesforce.com/services/apexrest/UpdateRecord:: Error - The remote server returned an error: (401) Unauthorized ERROR.
anyone help me to figure out this.
I am working on integration with docusign.
I have created an Rest Resouce class to update record in salesforce, and I have give this class URL like
https://test.salesforce.com/apexrest/services/UpdateRecord
Now docusign is calling this URL when ever the docusign database updated. But while calling this URL docusign getting
https://cs5.salesforce.com/services/apexrest/UpdateRecord:: Error - The remote server returned an error: (401) Unauthorized ERROR.
public void sendTemplateWithDetails(){ String passString = authHeader(); //THIS METHOD CONTAINS ALL THE CREDENTIALS OF DOCUSIGN Http httpProtocol = new Http(); HttpRequest request = new HttpRequest(); String endpoint = templateWrap.uri+'/envelopes'; String xmlStr; if(oppty.id != null){ xmlStr = '<envelopeDefinition xmlns=\'http://www.docusign.com/restapi\'>' + '<accountId>' + oppty.accountId + '</accountId>' + '<status>sent</status>' + // 'sent' to send envelope, 'created' to save as draft envelope '<emailSubject>DocuSign API Call - Signature request from template</emailSubject>' + '<templateId>' + templateId + '</templateId>' + '<templateRoles>' + '<templateRole>' + '<name>' + Account.Name+ '</name>' + '<email>' + Account.personEmail+ '</email>' + '<roleName>' + 'Client' + '</roleName>' + '</templateRole>' + '</templateRoles>' + '<eventNotification>' + '<EnvelopeEvents>' + '<envelopeEvent>' + '<envelopeEventStatusCode>'+'Completed'+'</envelopeEventStatusCode>' + '</envelopeEvent>' + '<envelopeEvent>' + '<envelopeEventStatusCode>'+'Delivered'+'</envelopeEventStatusCode>' + '</envelopeEvent>' + '</EnvelopeEvents>' + '<loggingEnabled>'+'true'+'</loggingEnabled>' + '<recipientEvents>' + '<recipientEvent>' + '<recipientEventStatusCode>'+'Delivered'+'</recipientEventStatusCode>' + '</recipientEvent>' + '<recipientEvent>' + '<recipientEventStatusCode>'+'Completed'+'</recipientEventStatusCode>' + '</recipientEvent>' + '</recipientEvents>' + '<url>'+'https://cs5.salesforce.com/services/apexrest/UpdateOpportunityStatus'+'</url>'+ '</eventNotification>'+ '</envelopeDefinition>'; } request.setEndPoint(endpoint); request.setBody(xmlStr); request.setMethod('GET'); request.setHeader('Content-Type', 'application/xml'); request.setHeader('Content-Disposition', 'form-data'); request.setHeader('X-DocuSign-Authentication', passString); system.debug('***********request body***'+request.getBody()); HttpResponse response1 = httpProtocol.send(request);How to authenticate to salesforce, when external system calling our URL to update records?
anyone help me to figure out this.
I think you forgot to set X-SFDC-Session header in request.