I'm new to the Rally world and am struggling through how to use the RallyRestAPI. There are a number of examples of how to query Rally to get back pertinent information that I have found most helpful. What I'm trying to do is create a C# command line tool to add users to a project. It appears that I use the RallyRestAPI.Create("projectpermission",some dynamic json object) interface to accomplish the creation. My problem is understanding the "some dynamic json object" part. I'm not sure how to correctly set it up. If someone has a small example of how to set it up, I would appreciate it.
Here's a code sample illustrating how to do this. Note that:
UserID running the code to create permissions must be a Workspace or Subscription Administrator
User must already have permissions in the Workspace (i.e be a Workspace User) in order for the ProjectPermission creation to succeed
namespace RestExample_AddUsersToProject {
class Program
{
static void Main(string[] args)
{
String userName = "user#company.com";
String userPassword = "topsecret";
String serverUrl = "https://rally1.rallydev.com";
String wsapiVersion = "1.38";
RallyRestApi restApi = new RallyRestApi(
userName,
userPassword,
serverUrl,
wsapiVersion
);
restApi.Headers[RallyRestApi.HeaderType.Vendor] = "Rally Software";
restApi.Headers[RallyRestApi.HeaderType.Name] = "RestExample_AddUsersToProject";
// Query for Project for which we want to add permissions
Request projectRequest = new Request("project");
projectRequest.Fetch = new List<string>()
{
"Name",
"Owner",
"State",
"Description"
};
String projectName = "Avalanche Hazard Mapping";
projectRequest.Query = new Query("Name", Query.Operator.Equals, projectName);
QueryResult queryProjectResults = restApi.Query(projectRequest);
var myProject = queryProjectResults.Results.First();
String myProjectReference = myProject["_ref"];
Console.WriteLine("Project Name: " + myProject["Name"]);
Console.WriteLine("State: " + myProject["State"]);
// Query for User for whom we wish to add ProjectPermission
Request userRequest = new Request("user");
userRequest.Fetch = new List<string>()
{
"UserName",
"Subscription",
"DisplayName"
};
// User needing the permissions
userRequest.Query = new Query("UserName", Query.Operator.Equals, "\"boromir#midearth.com\"");
QueryResult queryUserResults = restApi.Query(userRequest);
var myUser = queryUserResults.Results.First();
String myUserReference = myUser["_ref"];
Console.WriteLine("Username: " + myUser["UserName"]);
Console.WriteLine("Display Name: " + myUser["DisplayName"]);
Console.WriteLine("Subscription: " + myUser["Subscription"]);
// Setup required ProjectPermission data
DynamicJsonObject newProjectPermission = new DynamicJsonObject();
newProjectPermission["User"] = myUser;
newProjectPermission["Project"] = myProject;
newProjectPermission["Role"] = "Editor";
// Create the permission in Rally
CreateResult addProjectPermissionResult = restApi.Create("ProjectPermission", newProjectPermission);
DynamicJsonObject fetchedProjectPermission = restApi.GetByReference(addProjectPermissionResult.Reference, "Name");
Console.WriteLine("Created ProjectPermission with Role: " + fetchedProjectPermission["Name"]);
}
}
}
There are some very basic examples of CRUD + querying here:
http://developer.rallydev.com/help/rest-api-net
The general flow will always be to create a new DynamicJsonObject, set the appropriate fields and then pass that object to the Create method of an RallyRestApi.
Related
I'm trying to implement the SMS authentication with the aid of the DocuSign-SDK library.
var signer = new Signer {...};
signer.RequireIdLookup = "true";
signer.IdCheckConfigurationName = "SMS Auth $";
signer.SmsAuthentication = new RecipientSMSAuthentication {
SenderProvidedNumbers = new List<string> {
"0171*******"
}
};
When I try to send this envelope to the DocuSign API it will reply with the following error message:
Error calling CreateEnvelope:
{"errorCode":"INVALIDAUTHENTICATIONSETUP","message":"Recipient phone
number is invalid. Phone number for SMS Authentication: provided is
invalid. }
INVALIDAUTHENTICATIONSETUP: Authentication is not setup correctly for the recipient.
Is there something I have to enable on the DocuSign Admin page? I couldn't find any feature or something like that I need to enable.
Did I implement it the wrong way? Maybe someone can give me some suggestions.
Thanks
BTW: The given phone number should be valid.
EDIT:
When I'm using the new method as #Inbar wrote, I can't get the needed workflowId from the AccountsApi.
var client = new ApiClient(ApiClient.Demo_REST_BasePath);
var token = "eyJ1...";
client.Configuration.DefaultHeader.Add("Authorization", "Bearer " + token);
var accountsApi = new AccountsApi(client);
var response = accountsApi.GetAccountIdentityVerification(accountId);
var result = response.IdentityVerification; // Is empty. Why?
It seems that I have no IdentityVerification options which I can use for the authentication.
How can I enable such IdentityVerification options?
Or what else do I need to pay attention to?
Your code is using the older method, the new method code is provided in GitHub, I'll post it here too. You can find the article on Dev Center.
string workflowId = phoneAuthWorkflow.WorkflowId;
EnvelopeDefinition env = new EnvelopeDefinition()
{
EnvelopeIdStamping = "true",
EmailSubject = "Please Sign",
EmailBlurb = "Sample text for email body",
Status = "Sent"
};
byte[] buffer = System.IO.File.ReadAllBytes(docPdf);
// Add a document
Document doc1 = new Document()
{
DocumentId = "1",
FileExtension = "pdf",
Name = "Lorem",
DocumentBase64 = Convert.ToBase64String(buffer)
};
// Create your signature tab
env.Documents = new List<Document> { doc1 };
SignHere signHere1 = new SignHere
{
AnchorString = "/sn1/",
AnchorUnits = "pixels",
AnchorXOffset = "10",
AnchorYOffset = "20"
};
// Tabs are set per recipient/signer
Tabs signer1Tabs = new Tabs
{
SignHereTabs = new List<SignHere> { signHere1 }
};
string workflowId = workflowId;
RecipientIdentityVerification workflow = new RecipientIdentityVerification()
{
WorkflowId = workflowId,
InputOptions = new List<RecipientIdentityInputOption> {
new RecipientIdentityInputOption
{
Name = "phone_number_list",
ValueType = "PhoneNumberList",
PhoneNumberList = new List<RecipientIdentityPhoneNumber>
{
new RecipientIdentityPhoneNumber
{
Number = phoneNumber,
CountryCode = countryAreaCode,
}
}
}
}
};
Signer signer1 = new Signer()
{
Name = signerName,
Email = signerEmail,
RoutingOrder = "1",
Status = "Created",
DeliveryMethod = "Email",
RecipientId = "1", //represents your {RECIPIENT_ID},
Tabs = signer1Tabs,
IdentityVerification = workflow,
};
Recipients recipients = new Recipients();
recipients.Signers = new List<Signer> { signer1 };
env.Recipients = recipients;
I've created a new developer account on DocuSign and created a small test app in order to request identity verification options. Fortunately, that was working now and I got all available options but I do not understand why this is not working for my other developer account ("old").
When I compare both accounts I don't see the "Identity Verification" setting in the "old" account.
It is possible to activate this "Identity Verification" setting for my "old" dev account?
I guess that enabling this feature would solve the problem.
EDIT:
Ok, I've solved the problem.
I figured out that no IDV was configured for my developer account. In that case, the identity_verification call will return an empty array.
see: https://developers.docusign.com/docs/esign-rest-api/how-to/id-verification/
Also, I have read the following note in the DocuSign documentation:
Note: Phone authentication may not be enabled for some older developer
accounts. If you cannot choose to use phone authentication for your
account, contact support to request access. see:
https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/recipients/auth/#id-verification-idv
So I contacted DocuSign support and they give me access to the IDV accordingly.
Now it is working fine.
Please excuse me for asking what is probably an easy question. I am trying to use a Template that I created in my DocuSign account. I am using C# and using the Nuget package api. I am needing to get the template so that I can fill it out and send the envelope. I can send out an envelope just fine, I am now trying to just make it look better by using the template option.
As I stated above, I have the complete process working, I am just trying to use the Templates now rather than a document that I am building through HTML. I have looked all through the Nuget API and everything I see for getting Templates looks like it has to be from an existing document. All I am trying to do is get a list of templates, select the one that I want and then fill in the fields appropriately then send the document. Any help would be awesome!
See our example code here - https://github.com/docusign/eg-03-csharp-auth-code-grant-core/blob/master/eg-03-csharp-auth-code-grant-core/Controllers/Eg009UseTemplateController.cs
Let me copy/paste the relevant code into here:
string DoWork (string signerEmail, string signerName, string ccEmail,
string ccName, string accessToken, string basePath,
string accountId, string templateId)
{
// Data for this method
// signerEmail
// signerName
// ccEmail
// ccName
// accessToken
// basePath
// accountId
// templateId
var config = new Configuration(new ApiClient(basePath));
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(config);
EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId);
EnvelopeSummary result = envelopesApi.CreateEnvelope(accountId, envelope);
return result.EnvelopeId;
}
private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName,
string ccEmail, string ccName, string templateId)
{
// Data for this method
// signerEmail
// signerName
// ccEmail
// ccName
// templateId
EnvelopeDefinition env = new EnvelopeDefinition();
env.TemplateId = templateId;
TemplateRole signer1 = new TemplateRole();
signer1.Email = signerEmail;
signer1.Name = signerName;
signer1.RoleName = "signer";
TemplateRole cc1 = new TemplateRole();
cc1.Email = ccEmail;
cc1.Name = ccName;
cc1.RoleName = "cc";
env.TemplateRoles = new List<TemplateRole> { signer1, cc1 };
env.Status = "sent";
return env;
}
// ***DS.snippet.0.end
I'm trying to get the transaction ID by AuthorizeAndCapture method from AuthorizeNet API.
private static void CreateTransaction(long profileId, long paymentProfileId)
{
CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey);
var response = target.AuthorizeAndCapture(profileId.ToString(), paymentProfileId.ToString(), 1020.00M);
Console.WriteLine("Hola" + response.TransactionID);
}
But, when i execute the method, the property response.TransactionID returns empty.
I tried to change from sandbox to production and doesn't works neither.
I solve the issue using another gateway of the Authorize Net
private static void CreateTransaction(long profileId, long paymentProfileId)
{
Gateway target = new Gateway(ApiLogin, TransactionKey, true);
Customer cust = new Customer {ProfileID = profileId.ToString()};
IGatewayRequest request = new AuthorizationRequest("4111111111111111", "0224", 20.10M,
"AuthCap transaction approved testing", true);
request.AddCustomer("31358164", "bla_bla#bla.com", "", "", "street", "City",
"State","256984");
const string description = "AuthCap transaction approved testing";
var actual = target.Send(request, description);
Into "actual" we found transactionID.
I hope to help others.
First, I open Facebook Developers page, and I create new App. ( I get AppID, AppSecret values)
I want create Unit Test method for do Post to the wall, and later delete the post.
publish_stream, publish_actions
Manually, I do this 3 steps
Open url
https://graph.facebook.com/oauth/authorize?client_id=xxxxx&redirect_uri=http://www.kiquenet.com/&scope=publish_stream,publish_actions
Then, this url opened, and I get the code value:
http://www.kiquenet.com/?code=A....3qhOw#=
And then, open this url and I get the access token value:
https://graph.facebook.com/oauth/access_token?client_id=xxxxx&redirect_uri=http://www.kiquenet.com/&scope=publish_stream,publish_actions&client_secret=zzzzz&code=A...3qhOw#=
Finally, I get the access token:
const string token = "C...SNo";
My code now is for my unit test is working. Only I need do the delete.
using Facebook;
[TestMethod]
public void Post_to_the_wall()
{
var client = new FacebookClient(token);
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new
{
name = "View on Zombo",
link = "http://www.zombo.com",
};
parameters.privacy = new
{
value = "ALL_FRIENDS",
};
dynamic result = client.Post("me/feed", parameters);
// TODO: NOW, delete the post ???
}
How can I do programmatically the 3 Manually steps ?
My facebook app uses the Facebook C# SDK to publish to a user's Facebook profile. I'm currently publishing multiple posts with one attachment, but I'd much rather publish one summary post with multiple attachments. I've done this with the JavaScript API, but is it possible with the C# SDK?
This is my current publish code:
FacebookApp app = new FacebookApp(user.AccessToken);
string userFeedPath = String.Format("/{0}/feed/", user.FacebookUserId);
string message = String.Format("{0} earned an achievement in {1}",
user.SteamUserId, achievement.Game.Name);
dynamic parameters = new ExpandoObject();
parameters.link = achievement.Game.StatsUrl;
parameters.message = message;
parameters.name = achievement.Name;
parameters.description = achievement.Description;
parameters.picture = achievement.ImageUrl;
app.Api(userFeedPath, parameters, HttpMethod.Post);
We currently don't support multiple attachments. As far as I know you can't publish multiple attachments with either the graph or rest api. If you have a sample that shows how to do it, I will get it implemented in the SDK.
i have the same code as yours but it doesent work for me. I am trying this:
public void plesni()
{
try
{
dynamic parameters = new ExpandoObject();
parameters.message = "xxxxxxx";
parameters.link = "xxxxxxxx";
// parameters.picture=""
parameters.name = "xxxxxx";
parameters.caption = "xxxxxxx";
parameters.description = "xxxxxxxxxx";
parameters.actions = new
{
name = "xxxxxxx",
link = "http://www.xxxxxxxxxxxxxx.com",
};
parameters.privacy = new
{
value = "ALL_FRIENDS",
};
parameters.targeting = new
{
countries = "US",
regions = "6,53",
locales = "6",
};
dynamic result = app.Api("/uid/feed/", parameters, HttpMethod.Post);
// app.Api("/uid/feed", parameters);
Response.Write("Sucess");
}
catch (FacebookOAuthException)
{
Response.Write("...... <br/>");
}
}
if instead of uid I put me it works fine.
I am hoping for your help.
Have a good day.