I have been trying to send a docusign envelope from Salesforce using the docusign SOAP API. I am using the CreateEnvelopeFromTemplates method of the Docusign API, I have a functional template created in my docusign sandbox, but everytime I send the request I get an Unspecified Error in my response. Below is the code the I am using
wwwDocusignNetApi30.EnvelopeInformation envelope = new wwwDocusignNetApi30.EnvelopeInformation();
envelope.Subject = 'Envelope Subject' ;
envelope.EmailBlurb = 'Email Blurb';
envelope.AccountId = '********-****-****-****-************';
//use custom field to store the id of the record that initiated the transaction
envelope.CustomFields = new wwwDocusignNetApi30.ArrayOfCustomField();
envelope.CustomFields.CustomField = new wwwDocusignNetApi30.CustomField[2];
wwwDocusignNetApi30.CustomField myCustomField = new wwwDocusignNetApi30.CustomField();
myCustomField.Name = 'DSFSSourceObjectId';
myCustomField.Value = '0012600000PQn9g';
myCustomField.Show = 'false';
myCustomField.Required = 'false';
myCustomField.CustomFieldType = 'Text';
envelope.CustomFields.CustomField.add(myCustomField);
wwwDocusignNetApi30.ArrayOfTemplateReference templateArray = new wwwDocusignNetApi30.ArrayOfTemplateReference();
templateArray.TemplateReference = new wwwDocusignNetApi30.TemplateReference[2];
wwwDocusignNetApi30.TemplateReference templat = new wwwDocusignNetApi30.TemplateReference();// TemplateReferences
templat.Template = '********-****-****-****-************';
templat.TemplateLocation = 'Server';
wwwDocusignNetApi30.ArrayOfRecipient1 recArray = new wwwDocusignNetApi30.ArrayOfRecipient1();
recArray.Recipient = new wwwDocusignNetApi30.Recipient[2];
wwwDocusignNetApi30.Recipient recipient = new wwwDocusignNetApi30.Recipient();
recipient.ID = 100987;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 2;
recipient.Email = 'example#example.com';
recipient.UserName = 'Test';
recArray.Recipient.add(recipient);
wwwDocusignNetApi30.TemplateReferenceRoleAssignment trra = new wwwDocusignNetApi30.TemplateReferenceRoleAssignment();
trra.RoleName='Signer 1';
trra.RecipientID = recipient.ID;
wwwDocusignNetApi30.ArrayOfTemplateReferenceRoleAssignment roleArray = new wwwDocusignNetApi30.ArrayOfTemplateReferenceRoleAssignment();
roleArray.RoleAssignment = new wwwDocusignNetApi30.TemplateReferenceRoleAssignment[1];
roleArray.RoleAssignment.add(trra);
templat.RoleAssignments = new wwwDocusignNetApi30.ArrayOfTemplateReferenceRoleAssignment();
templat.RoleAssignments = (roleArray);
templateArray.TemplateReference.add(templat);
String auth = '<DocuSignCredentials><Username>********-****-****-****-************</Username><Password>PASSWORD</Password><IntegratorKey>********-****-****-****-************</IntegratorKey></DocuSignCredentials>';
wwwDocusignNetApi30.APIServiceSoap service = new wwwDocusignNetApi30.APIServiceSoap();
service.inputHttpHeaders_x = new Map<String, String>();
service.inputHttpHeaders_x.put('X-DocuSign-Authentication',auth);
service.CreateEnvelopeFromTemplates(templateArray,recArray,envelope,true);
Below is the response I receive:
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unspecified_Error faultcode=soap:Server faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx
Since the error message is vague, I am not able to debug the issue. Any help is appreciated.
I suggest that you start with a simpler request. Look at the recipes on github.com/docusign that start with sfdc
Get the simpler request working, then add features to get it to your needs.
One thing I did notice was that you are not giving a routing order of 1 to your only recipient. But that's probably OK.
I'm not sure that your template reference is correct since you should not be using composite templates for a simple template reference. Unfortunately I don't have a lot of experience with the soap api. HTH.
Related
I have implemented the custom security on my reporting services 2016 and it displays the login page once the URL for reporting services is typed on browser URL bar (either reports or reportserver)
I am using the following code to pass the Credentials
when i use the code WITHOUT my security extension it works and looks like this
ICredentials _executionCredentials;
CredentialCache myCache = new CredentialCache();
Uri reportServerUri = new Uri(ReportServerUrl);
myCache.Add(new Uri(reportServerUri.GetLeftPart(UriPartial.Authority)),
"NTLM", new NetworkCredential(MyUserName, MyUserPassword));
_executionCredentials = myCache;
when i use the code WITH the security extension it doesnt work and looks like this
ICredentials _executionCredentials;
CredentialCache myCache = new CredentialCache();
Uri reportServerUri = new Uri(ReportServerUrl);
myCache.Add(new Uri(reportServerUri.GetLeftPart(UriPartial.Authority)),
"Basic", new NetworkCredential(MyUserName, MyUserPassword));
_executionCredentials = myCache;
and i get an Exception saying "The response to this POST request did not contain a 'location' header. That is not supported by this client." when i actually use this credentials
Is "basic" the wrong option ?
Have anyone done this ?
Update 1
Well it turns out that my SSRS is expecting an Authorisation cookie
which i am unable to pass (according to fiddler, there is no cookie)
HttpWebRequest request;
request = (HttpWebRequest)HttpWebRequest.Create("http://mylocalcomputerwithRS/Reports_SQL2016/api/v1.0");
CookieContainer cookieJar = new CookieContainer();
request.CookieContainer = cookieJar;
Cookie authCookie = new Cookie("sqlAuthCookie", "username:password");
authCookie.Domain = ".mydomain.mylocalcomputerwithRS";
if (authCookie != null)
request.CookieContainer.Add(authCookie);
request.Timeout = -1;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)request.GetResponse();
That's how I got it (SSRS 2017; api v2.0). I took the value for the "body" from Fiddler:
var handler = new HttpClientHandler();
var httpClient = new HttpClient(handler);
Assert.AreEqual(0, handler.CookieContainer.Count);
// Create a login form
var body = new Dictionary<string, string>()
{
{"__VIEWSTATE", "9cZYKBmLKR3EbLhJvaf1JI7LZ4cc0244Hpcpzt/2MsDy+ccwNaw9hswvzwepb4InPxvrgR0FJ/TpZWbLZGNEIuD/dmmqy0qXNm5/6VMn9eV+SBbdAhSupsEhmbuTTrg7sjtRig==" },
{"__VIEWSTATEGENERATOR", "480DEEB3"},
{ "__EVENTVALIDATION", "IS0IRlkvSTMCa7SfuB/lrh9f5TpFSB2wpqBZGzpoT/aKGsI5zSjooNO9QvxIh+QIvcbPFDOqTD7R0VDOH8CWkX4T4Fs29e6IL92qPik3euu5QpidxJB14t/WSqBywIMEWXy6lfVTsTWAkkMJRX8DX7OwIhSWZAEbWZUyJRSpXZK5k74jl4x85OZJ19hyfE9qwatskQ=="},
{"txtUserName", "User"},
{"txtPassword", "1"},
{"btnLogin","Войти"}
};
var content = new FormUrlEncodedContent(body);
// POST to login form
var response = await httpClient.PostAsync("http://127.0.0.1:777/ReportServer/Logon.aspx", content);
// Check the cookies created by server
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
var cookies = handler.CookieContainer.GetCookies(new Uri("http://127.0.0.1:777/ReportServer"));
Assert.AreEqual("sqlAuthCookie", cookies[0].Name);
// Make new request to secured resource
var myresponse = await httpClient.GetAsync("http://127.0.0.1:777/Reports/api/v2.0/Folders");
var stringContent = await myresponse.Content.ReadAsStringAsync();
Console.Write(stringContent);
As an alternative you can customize SSRS Custom Security Sample quite a bit.
I forked Microsoft's Custom Security Sample to do just what you are describing (needed the functionality at a client long ago and reimplemented as a shareable project on GitHub).
https://github.com/sonrai-LLC/ExtRSAuth
I created a YouTube walkthrough as well to show how one can extend and debug SSRS security with this ExtRSAuth SSRS security assembly https://www.youtube.com/watch?v=tnsWChwW7lA
TL; DR; just bypass the Microsoft example auth check in Login.aspx.cs and put your auth in Page_Load() or Page_Init() event of Login.aspx.cs- wherever you want to perform some custom logging check- and then immediately redirect auth'd user to their requested URI.
I would like to fetch a user's email using the C# Facebook SDK. How can I do so? I've tried the code below, but I just get an empty email. Is it because I somehow need to ask for more rights? If so, how do I do that?
Facebook.FacebookClient fbc = new Facebook.FacebookClient(user.MobileServiceAuthenticationToken);
dynamic clientCredentials = await fbc.GetTaskAsync("oauth/access_token",
new{client_id = facebookClientId,client_secret = facebookClientSecret,
grant_type = "client_credentials",redirect_uri = "https://xxx.azure-mobile.net/signin-facebook"});
fbc.AccessToken = clientCredentials.access_token;
fbc.AppId = facebookClientId;
fbc.AppSecret = facebookClientSecret;
string id = user.UserId.Replace("Facebook:", string.Empty);
dynamic result = await fbc.GetTaskAsync(id + "?fields=id,name,picture,last_name,first_name,gender");
Best regards
TJ78
You need to gather the email permission in the login Url's scope parameter, otherwise you will not be able to receive the email field.
I am writing a Restful web service in symfony2. Same service is working fine on the localhost returning the response data but not on the server.
I print_r() the response variable and it is showing the data array.
$user = new Users();
$user->setUsername($paramFetcher->get('email'));
$password = $paramFetcher->get('password');
$user->setUserType('business');
if($password==""){
$user->setPassword(rand(0,1000));
}else{
$user->setPassword($password);
}
$data['UserDetails']['id'] = $user->getId();
$data['UserDetails']['username'] = $user->getUsername();
$data['UserDetails']['password'] = $user->getPassword();
$data['UserDetails']['usertype'] = $user->getUserType();
$em->persist($user);
$em->flush();
//print_r($data); print_r($buss);
$response[]=array("code"=>200,"message"=>"success","data"=>$data);
Please guide
If this code is inside a controller then your function will need to return a response. If you want to output json then you need to return a JsonResponse object:
return new \Symfony\Component\HttpFoundation\JsonResponse($response);
I'm trying to program an application connecting to a website not spammer but some thing like that .
But there is one problem :
In that website you will login by an html form and I know the target php page and parameters so with c# I login like this :
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-urlencoded";
wc.UploadString("http://example.com/login/check.php", "username=US&password=PW");
MessageBox.Show(result);
}
after logining in when I want to ( for example ) send a post ( like codes below ) the answer is that you are not loged in !
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-urlencoded";
wc.UploadString("http://example.com/post/send.php", "title=T&body=B");
MessageBox.Show(result);
}
I think the problem is that the session is closed .
what can I do ?
I dont know if you found the answer but try this
WebClient webClient = new WebClient();
string url = #"http://example.com/login/check.php";
var postData = new System.Collections.Specialized.NameValueCollection();
byte[] bytes = webClient.UploadValues(url,"POST",postData);
string text = System.Text.Encoding.ASCII.GetString(bytes);
use Fiddler to look for the parameters.
I'm currently trying to use the GData .net API
Here is the documentation I'm using http://code.google.com/googleapps/domain/audit/docs/1.0/audit_developers_guide_protocol.html#retrieving_all_mailbox_status
What I'm trying to do is to use 2 legged authentication to do this example
using System;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...
MailMonitor monitor = new MailMonitor();
monitor.BeginDate = new DateTime(2009, 6, 15);
monitor.EndDate = new DateTime(2009, 6, 30, 23, 20, 0);
monitor.IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY;
monitor.DraftMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.ChatMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.DestinationUserName = "namrata";
AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("admin#example.com", "p#55w0rd");
MailMonitor monitorEntry = service.CreateMailMonitor("abhishek", monitor);
I've gotten as far as
var monitor = new MailMonitor
{
EndDate = DateTime.Now.AddDays(1),
IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE,
OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY,
DraftMonitorLevel = MonitorLevel.FULL_MESSAGE,
ChatMonitorLevel = MonitorLevel.FULL_MESSAGE,
DestinationUserName = "MYUSER"
};
var service = new AuditService("MYDOMAIN", "MYDOMAIN-auditapp-v1");
var requestFactory = new GOAuthRequestFactory("auditapi", "MYDOMAIN-auditapp-v1")
{
ConsumerKey = "MYDOMAIN",
ConsumerSecret = "MYKEY"
};
service.RequestFactory = requestFactory;
var monitorEntry = service.CreateMailMonitor("MYUSER", monitor);
This is trying to setup a monitor for any emails coming or going for one day. The response is Unknown authorization header (Error 401).
I got the key from following this guide http://code.google.com/googleapps/domain/articles/2lo-in-tasks-for-admins.html
I've no idea how to debug this, I can't find an example of 2 legged auth with the Email Audit API and I can't use wireshark because this is encrypted traffic.
What key did you use?
Remember API key is not the same as Consumer Secret. Consumer Secret is something which is unique to your domain.
You can find your consumer secret by going to your domain's Cpanel -> Advanced Settings -> Manage OAuth Domain Key. This is the secret your domain and Google share.
Here is a doc for your reference.