Recent changes to Rally C# REST API? - rally

1) Earlier this week I was able to create defects and testcases using the Create method, which took 2 arguments at the time (a string and the DynamicJsonObject). However now, it needs three. I understand that one of these is now the workspace reference. How do I go about getting the workspace reference? For creating defects and testcases, I am using an empty string, and this seems to be working correctly for me. Is this to be expected?
2) For creating test case results, I am having a bit of trouble.
DynamicJsonObject newTCResult = new DynamicJsonObject();
newTCResult["Date"] = DateTime.Now.ToString("yyyyMMdd");
newTCResult["TestCase"] = "/testcase/11271454106";
newTCResult["Notes"] = "test";
newTCResult["Build"] = "13.1.0.90";
newTCResult["Verdict"] = "Pass";
CreateResult cr = restApi.Create(" ", "TestCaseResult", newTCResult);
As of right now, absolutely nothing is happening when I run this. I was able to do this successfully earlier this week (when I was able to use the Create method with two arguments). I feel that the problem is because I don't have a valid workspace reference. I followed the suggestion of another user in a similar question prior to this which worked for earlier, however now I am having this problem.

I was finally able to resolve this. It appears that the date field needs to be converted to UTC, so my code now looks something like this
newTCResult["Date"] = DateTime.UtcNow.ToString("o");
After making that small change results were working correctly.

It's somewhat surprising that Creates on Stories or Defects work with an empty string for a Workspace ref, although I suspect that on the server-side, the Webservices API is just using Default Workspace for the User of concern.
Either way, here's how you can get a ref to the Workspace of interest:
String myWorkspaceName = "My Workspace";
// Get a Reference to Target Workspace
Request workspaceRequest = new Request("workspace");
workspaceRequest.Fetch = new List<string>()
{
"Name",
"ObjectID"
};
workspaceRequest.Query = new Query("Name", Query.Operator.Equals, myWorkspaceName);
QueryResult workspaceQueryResults = restApi.Query(workspaceRequest);
var targetWorkspace = workspaceQueryResults.Results.First();
Console.WriteLine("Found Target Workspace: " + targetWorkspace["Name"]);
String workspaceRef = targetWorkspace["_ref"];
You can then use workspaceRef in your call to restApi.Create().

Related

What does this podio error mean and how do i resolve it?

I am trying to update an item on podio through their Java API. It worked fine for a while, but now, but after some time it gave me this error:
APIException [status=Conflict, error=conflict, description=A newer version exists , parameters=null]
Right now, if I sent another request to update the item that had this error, it will return the same error. I don't understand.
What does this error mean? and how do i solve it? Is that item going to give me the same error error forever?
Here's a snippet of my code:
List<FieldValuesUpdate> fields = new ArrayList<>();
String valueSubId = "value";
fields.add(new FieldValuesUpdate(1234567890, valueSubId, something.getName()));
fields.add(new FieldValuesUpdate(1234567891, valueSubId, something.getCode()));
fields.add(new FieldValuesUpdate(1234567892, valueSubId, something.getAddress()));
fields.add(new FieldValuesUpdate(1234567893, valueSubId, something.getStatus()));
ItemUpdate itemUpdate = new ItemUpdate(null, fields);
int itemId = 123444;
podioItemApi.updateItem(itemId, itemUpdate, true, false);
Looks like you are trying to create item and adding fields but your app is updated and maybe some of fields doesn't exist anymore.
Please send full http request and response for your call, that will definitely help understanding what's happening.
Had the same issue as well.
And as mentioned earlier, it has to do with the revision provided. Using the Java API, the revision is set automatically. Therefore, if an entry has been updated manually it will have a revision of >0, while example by JayDoe will leave it at 0 which is the conflict.
I decided not to hack the API, but use it the way an update workflow is meant to be used. reading the entry first, then setting its revision into the ItemUpdate object.

PyRal Rally Specific queries work but generic queries not returning data

When I use the PyRal get() function no results are returned, but if I use specific built-in get functions (e.g., getProjects(), getWorkspaces()) all data is returned correctly. Am I using the general get() incorrectly or do I have a configuration issue?
For the setup:
import sys
from pyral import Rally, rallyWorkset
server, user, password, apikey, workspace, project = <appropriate values>
rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project)
These calls respond correctly (i.e., expected data returned):
workspacesAll = rally.getWorkspaces()
projectsAll = rally.getProjects(workspace=workspace)
No data returned for this call, no errors. The User Story exists in Rally.
query_criteria = 'FormattedID = "US220220"'
response = rally.get('HierarchicalRequirement', fetch=True, query=query_criteria)
Have also tried using "UserStory" instead of "HierarchicalRequirement" and other query criteria all without success.
It will work if you go thru all Projects (not parent):
query_criteria = 'FormattedID = "US220220"'
response_req = rally.get('HierarchicalRequirement', fetch=True, projectScopeDown=True, query=query_criteria)
response = response_req.next()
print response.details()

Application name is not set. Call Builder#setApplicationName. error

Application: Connecting to BigQuery using BigQuery APIs for Java
Environment: Eclipse, Windows 7
My application was running fine until last night. I've made no changes (except for restarting my computer) and my code is suddenly giving me this error:
Application name is not set. Call Builder#setApplicationName.
Thankfully I had a tar'd version of my workspace from last night. I ran a folder compare and found the local_db.bin file was different. I deleted the existing local_db.bin file and tried to run the program again. And it worked fine!
Any idea why this might have happened?
Hopefully this will help anyone else who stumbles upon this issue.
Try this to set your application name
Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
.setHttpRequestInitializer(credential)
.setApplicationName("Your app name")
.build();
If you are working with only Firebase Dynamic Links without Android or iOS app
Try this.
builder.setApplicationName(firebaseUtil.getApplicationName());
FirebaseUtil is custom class add keys and application name to this class
FirebaseDynamicLinks.Builder builder = new FirebaseDynamicLinks.Builder(
GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), null);
// initialize with api key
FirebaseDynamicLinksRequestInitializer firebaseDynamicLinksRequestInitializer = new FirebaseDynamicLinksRequestInitializer(
firebaseUtil.getFirebaseApiKey());
builder.setFirebaseDynamicLinksRequestInitializer(firebaseDynamicLinksRequestInitializer);
builder.setApplicationName(firebaseUtil.getApplicationName());
// build dynamic links
FirebaseDynamicLinks firebasedynamiclinks = builder.build();
// create Firebase Dynamic Links request
CreateShortDynamicLinkRequest createShortLinkRequest = new CreateShortDynamicLinkRequest();
createShortLinkRequest.setLongDynamicLink(firebaseUtil.getFirebaseUrlPrefix() + "?link=" + urlToShorten);
Suffix suffix = new Suffix();
suffix.setOption(firebaseUtil.getShortSuffixOption());
createShortLinkRequest.setSuffix(suffix);
// request short url
FirebaseDynamicLinks.ShortLinks.Create request = firebasedynamiclinks.shortLinks()
.create(createShortLinkRequest);
CreateShortDynamicLinkResponse createShortDynamicLinkResponse = request.execute();

Fetching Publishing Pages from Pages Library in SharePoint 2010 ECMAScript OM

i want to fetch all the pages in a specific Publishing Web using JavaScript and Client Object Model, it keeps giving
The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
Here's the code,
var selectedDoc;
var ctx = new SP.ClientContext.get_current();
var site = ctx.get_site();
//('created ctx');
//loading the Library
var pagesLib = site.openWeb('/Ar/News').get_lists().getByTitle('Pages');
if (missionType == 'All') {
var query = new SP.CamlQuery();
query.set_viewXml("<View><RowLimit>10</RowLimit></View>");
selectedDoc = pagesLib.getItems(query);
ctx.load(selectedDoc,'Include(Title)');
ctx.executeQueryAsync(getAllNewsWithQuerySuccess(this,this.onListLoadSuccess), getAllNewsWithQueryFailure(this,this.onQueryFailed));
You might be missing a load call. Try this right after you assign pagesLib:
ctx.load(pagesLib);
I'm guessing the error is due to pagesLib not having been populated before you execute the CAML query against it.
You might be missing a load call. Try this right after you assign pagesLib:
ctx.load(pagesLib);
I'm guessing the error is due to pagesLib not having been populated before you execute the CAML query against it.

Querying into alternate workspaces with Rally C# API

I'm making a bunch of Rally API calls using the C# Rally Rest API Wrapper, with great success... except when I'm trying to query into a non-default workspace. For example, take this code:
public Project GetProject(string objectID)
{
Request request = new Request("Project");
// request.Workspace = "2354109555"; //"CTO:SST";
request.Query = new Query("ObjectID", Query.Operator.Equals, objectID);
QueryResult q = _restApi.Query(request);
foreach (var result in q.Results)
{
return CreateProjectFromResult(result);
}
return null;
}
If objectID is in the default workspace, the project is found. If it is not, it is not found. I've tried setting the Workspace property to the workspace object id, the workspace name, not setting it.. to no avail. I've also gone into Rally, switched my default workspace, and verified the switch in which projects are successfully obtained.
I've also triple checked the objectIDs for the projects and workspaces.
I'm officially stumped. Does anyone have the magic answer or something else I can try?
Much appreciated,
Orlando
I think you're 99 pct of the way there. When you specify a workspace attribute on your Request object, it needs to be in the form of a ref, i.e.:
request.Workspace = "/workspace/2354109555"; //"CTO:SST";
Your code should pull from that Workspace once you make that modification.