问题
I have a C# application using version 2.0.1.0 of the Rally Rest API for .NET. The application will successfully query Rally for data, but when I try to create an object, an error is returned indicating invalid key. This issue started today and is occurring for multiple users of the application. I use the following line of code to authenticate.
myRestApi = new RallyRestApi(Rally_username, Rally_password, Rally_URL, "v2.0", myProxy);
I have read some help online indicating the need for a security token, however this note makes me feel like that is not needed: "Note: When using any of the Rally REST Toolkits or the App SDK this will be automatically handled. "
I have tried updating to version 3.0 (Beta), but this does not resolve the problem.
回答1:
There are reports that using ApiKey instead of basic authentication with username/password resolves the invalid key error.
Rally .NET toolkit supports ApiKey authentication.
The constructor for v2.0.1:
restApi = new RallyRestApi("_abc123","https://rally1.rallydev.com","v2.0");
The constructor for v3.0.1:
restApi.Authenticate("_abc123", "https://rally1.rallydev.com", allowSSO: false);
回答2:
I was getting the same error and noticed it was not recognizing my username and password that I had stored in the <appSettings>
section of Web.config
.
For some reason it would not allow them to be read so I decided to store the credentials elsewhere, in Properties => Settings of my app and it has worked ever since.
Here's a code snippet of how the Rally API initialization looks like for me:
RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0");
string user = Properties.Settings.Default.username;
string pass = Properties.Settings.Default.password;
string rallyURL = Properties.Settings.Default.rallyURL;
restApi.Authenticate(user, pass, rallyURL, proxy: null, allowSSO: false);
Hope it helps!
来源:https://stackoverflow.com/questions/30492008/net-rally-restapi-error-not-authorized-to-perform-action-invalid-key-when-cr