.NET Toolkit for Rally REST API Documentation deprecated? - c#

I'm starting to work with Rally .NET API, in order to develop a plugin to import User Story into Enterprise Architect.
I have started by the examples in the following page: http://developer.help.rallydev.com/rest-api-net.
In the last one, for example, I got this errors:
//Create an item
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["Name"] = "My Defect";
CreateResult createResult = restApi.Create("defect", toCreate);
Error 1 No overload for method 'Create' takes 2 arguments
//Delete the item
OperationResult deleteResult = restApi.Delete(createResult.Reference);
Error 2 No overload for method 'Delete' takes 1 arguments
But the documentation here is different from the examples.
All in all, I would like to know any good sources of information to learn this Rally API and which is the correct implementation for the Create and Delete in the examples of the first page.
Thanks in advance,
Pedro

Sorry for the confusion - with the latest release of the .NET REST DLL (version 1.0.15), both the Create and Delete methods changed slightly - they now require a Workspace Ref:
String workspaceRef = "/workspace/12345678910";
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["Name"] = "My Defect";
CreateResult createResult = restApi.Create(workspaceRef, "defect", toCreate);
Delete should look like this:
OperationResult deleteResult = restApi.Delete(workspaceRef, createResult.Reference);
Or this:
myDefectObjectID = "12345678911";
OperationResult deleteResult = restApi.Delete(workspaceRef, "Defect", myDefectObjectID);
We'll work to get the documentation updated as quickly as possible. Thanks for pointing this out!

Related

LuisV3.PredictionOptions doesn't let me timezone - how to do it?

I figured I'd upgrade my LuisRecognizer to use LuisRecognizerOptionsV3. However I can't seem to set prediction options the way I like - how do I set the timezone? The v3 prediction options lack this field.
In my bot I am currently doing:
var predictionOptions = new LuisPredictionOptions();
predictionOptions.TimezoneOffset = turnContext.Activity.LocalTimestamp.Value.Offset.TotalMinutes;
and I can't figure out the equivalent in v3's version of the data structure.
The timezoneOffset parameter was mostly provided as a way to determine what day it is for the user in case they say something like "today" or "tomorrow." It also helps when the user enters a relative time like "in three hours." When using the timezoneOffset parameter, the returned entity is in the provided timezone rather than universal time.
In LUIS v3, instead of providing an offset you provide a DateTime reference and LUIS uses that to process relative time. You can see that documented here. Note that the datetimeReference property is only available in POST requests and not GET requests because you provide it in the request body and not as a query parameter.
Also note that the datetimeReference property is not currently available in the Bot Builder SDK. You can write your own code to access the LUIS API directly with an HttpClient, but if you'd still like a prebuilt SDK to handle things then you can use this NuGet package: Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime 3.0.0
Here's an example of how to use it:
var appId = new Guid("<LUIS APP ID>");
var client = new LUISRuntimeClient(new ApiKeyServiceClientCredentials("<SERVICE KEY>"));
client.Endpoint = "https://westus2.api.cognitive.microsoft.com";
var options = new PredictionRequestOptions(activity.LocalTimestamp.Value.DateTime);
var request = new PredictionRequest("Book a flight in three hours", options);
var response = await client.Prediction.GetSlotPredictionAsync(appId, "PRODUCTION", request);
Console.WriteLine(JsonConvert.SerializeObject(response.Prediction.Entities, Formatting.Indented));

C# Bound library method doesn't accept implementation parameter

Trying to implement the new SnapChat Creative Kit in Xamarin.iOS, I bound the SDK framework using Objective Sharpie. While following the official documentation (which only has implementation steps for swift and obj-c) for other SDKs wan not a problem - I successfully implemented Login Kit - I came to a stumble with this code while trying to send the content to SnapChat.
In particular, in the Documentation, to send the contents to the api, this code is used:
// swift
let snapImage = /* Set your image here */
let photo = SCSDKSnapPhoto(image: snapImage)
let snap = SCSDKSnapPhotoContent(snapPhoto: photo)
let api = SCSDKSnapAPI(content: snap)
api.startSnapping({ (error: Error?) in
/* Error handling */
})
According to the docs,
SCSDKPhotoSnapContent is an implementation of the SCSDKSnapContent protocol. It provides a way to model a photo Snap for sharing to Snapchat.
Here is my C# implementation:
var snapImage = GetCurrentScreenImage();
SCSDKSnapPhoto photo = new SCSDKSnapPhoto(snapImage);
SCSDKPhotoSnapContent snapPhoto = new SCSDKPhotoSnapContent(photo)
SCSDKSnapAPI api = new SCSDKSnapAPI(snapPhoto);
api.StartSnappingWithCompletionHandler((NSError error) =>
{
// Error handling
});
The problem is SCSDKSnapAPI constructor only accepts SCSDKSnapContent, which is an abstract class, and not its implementation, and I get an error calling it:
CS1503 Argument 1: cannot convert from 'SCSDKCreativeKit_Bindings.SCSDKPhotoSnapContent' to 'SCSDKCreativeKit_Bindings.SCSDKSnapContent'
EDIT:
ApiDefinition.cs
[Export("initWithContent:")]
IntPtr Constructor(SCSDKSnapContent content);
I tried adding another constructor like this:
[Export("initWithContent:SCSDKPhotoSnapContent")]
IntPtr Constructor(SCSDKPhtotoSnapContent content);
The code now builds, but I receive the following error code from SnapChat on callback:
SnapEncryptionMetadataUnexpectedStatusCode
I couldn't find a way to correctly implement SCSDKSnapContent in Xamarin.iOS. I did find a workaround, that sort of works. If you change constructor for SCSDKSnapAPI in the binding library from SCSDKSnapContent to one of its implementations (SCSDKPhotoSnapContent in my case), like this:
[Export("initWithContent:")]
IntPtr Constructor(SCSDKPhotoSnapContent content);
You can then correctly call SCSDKSnapAPI in Xamarin
var snapImage = GetCurrentScreenImage();
SCSDKSnapPhoto photo = new SCSDKSnapPhoto(snapImage);
SCSDKPhotoSnapContent snapPhoto = new SCSDKPhotoSnapContent(photo)
SCSDKSnapAPI api = new SCSDKSnapAPI(snapPhoto);
api.StartSnappingWithCompletionHandler((NSError error) =>
{
// Error handling
});

VersionOne: Getting message that VersionOneAPIConnector is obsolete and I should use V1Connector instead. But how?

I am trying to upgrade my c# programs to VersionOne.SDK.API version 15.3.0.0. I am getting a message that VersionOneAPIConnector is obsolete and that I should use V1Connector instead. When the ObjectModel API was discontinued, I had changed to doing everything with VersionOneAPIConnector using query.v1 (using HttpPost) and rest-1.v1/Data(using SendData). After getting the new version, I figured out how to use V1Connector and pass it to Services and then to use ExecutePassThroughQuery() to pass what had been the 2nd argument to HttpPost for my query.v1 code like this:
Original code:
Stream resultStream = _cx.HttpPost("/query.v1", System.Text.Encoding.UTF8.GetBytes(GetQueryForMembers()));
using (StreamReader reader = new StreamReader(resultStream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
New Code:
result = _service.ExecutePassThroughQuery(GetQueryForMembers());
Where GetQueryforMembers() is:
public static string GetQueryForMembers()
{
return #"
from: Member
select:
- Email
where:
AssetState: Active";
}
But, I can't figure out how to use V1Connector/IServices for my rest/SendData code. All the Rest examples on the VersionOne site now show using it from the API Console, not from stand-alone code. It looks like at least some of the things I was doing with Rest can be done via Services.executeOperation() or Services.Meta, but the V1 employee that I was working with to get rid of my Object Model code a few years ago had recommended only using the API for the connection and to otherwise use Rest and Query, so that I didn't have to worry about compatibility with .NET versions. But, from looking at the examples currently provided and the functionality available on the V1Connector/IServices classes, it looks like maybe V1 wants us to use Meta API rather than REST now? Or is there a way to use REST directly that I am missing? From looking at the source, I see there is an internal UseDataAPI() on the V1Connector that IServices uses. But, it only uses it in Save, ExecuteOperation and Retrieve and it doesn't look like any of those do what I'm trying to do.
This is an example, if what I was doing before with REST (where _passed_cx is a VersionOneAPIConnector)
string newDefect = string.Concat("<Asset href=\"/MentorG01/rest-1.v1/New/Defect\">",
"<Attribute name=\"Name\" act=\"set\">", cdata_attribute_value, "</Attribute>",
"<Relation name=\"Scope\" act=\"set\">",
"<Asset href=\"/MentorG01/rest-1.v1/Data/Scope/", project_oid.Split(':')[1], "\" idref=\"", project_oid, "\" />",
"</Relation>",
"</Asset>");
string url = "rest-1.v1/Data/Defect";
Stream resultStream = _passed_cx.SendData(url, newDefect);
Anyone know how to use rest-1.v1 with V1Connector? If so, can you provide an example?

Retrieving Profiles and connections - Parameter missing?

I use Google's .NET people API (v.1.25) and follow the documentation (https://developers.google.com/people/v1/read-people).
Under
Retrieve Profiles and Connections
Get the user's connections
for .NET the documentation gives this example code snippet:
PeopleResource.ConnectionsResource.ListRequest peopleRequest =
peopleService.People.Connections.List("people/me");
peopleRequest.PersonFields = "names,emailAddresses";
ListConnectionsResponse connectionsResponse = peopleRequest.Execute();
IList<Person> connections = connectionsResponse.Connections;
But PersonFields do not exist in the class ListRequest - nor does it exist in GetRequest as the doc suggests in the next example.
Do I misunderstand something or is there a fault in the docs or in the API?
It seems like you are using an old version of the library. If you browse the .NET documentation from the Install Client Libraries page it shows the version is 1.5.1.
If you browse to the ConnectionsResource.ListRequest documentation it shows that PersonFields exists.
Just use .Fields instead of .PersonFields. Also I had to declare the entire package name (Google.Apis.People.v1.). Example below.
Google.Apis.People.v1.People.PeopleService peopleService;
Google.Apis.People.v1.PeopleResource.ConnectionsResource.ListRequest peopleRequest = peopleService.People.Connections.List("people/me");
peopleRequest.Fields = "names,emailAddresses";
ListConnectionsResponse connectionsResponse = peopleRequest.Execute();
IList<Google.Apis.People.v1.Data.Person> connections = connectionsResponse.Connections;
Hope this helps.

Google Custom Search .NET API Compile issue with Fetch method

I am attempting to use the Google CustomSearch API for .NET using sample code from the following locations:
Steps for using Google custom search API in .NET
How can I do a search with Google Custom Search API for .NET?
http://astrocoder.com/search-using-google-custom-search/
The basic code in it's simplest form looks like:
string apiKey = "my-api-key";
string cseKey = "my-cse-id";
string query = "search query";
var bcsi = new BaseClientService.Initializer { ApiKey = apiKey };
var css = new CustomsearchService(bcsi);
var listRequest = css.Cse.List(query);
listRequest.Cx = cseKey;
Search search = listRequest.Fetch();
However, when I attempt to compile this, I am getting the following error:
'Google.Apis.Customsearch.v1.CseResource.ListRequest' does not
contain a definition for 'Fetch' and no extension method 'Fetch'
accepting a first argument of type
'Google.Apis.Customsearch.v1.CseResource.ListRequest' could be found
As far as I can tell, I have all of the required library files (I used NuGet to install the Google APIs). When I view the API documentation, I do not see a Fetch() method, however, all of the sample code I have been able to find shows the listRequest.Fetch() method call.
https://developers.google.com/resources/api-libraries/documentation/customsearch/v1/csharp/latest/classGoogle_1_1Apis_1_1Customsearch_1_1v1_1_1CseResource_1_1ListRequest-members.html
Instead of using Fetch() you can use the following.
Search search = listRequest.Execute();
The fetch() api has been replaced after version 1.4 but the sample code has not been updated yet.

Categories