Create a site term column with graph API - c#

I'm trying to add a new column to a site using MS Graph API. I followed the docs, which shows a Text column example, and that works. When I try to add a Term column I get an invalid request. Does anyone have any insight as to what I've done wrong?
See my code below.
var columnDef = new ColumnDefinition
{
DisplayName = "Tag",
EnforceUniqueValues = false,
Hidden = false,
Indexed = false,
Name = "Tag",
Term = new TermColumn
{
ShowFullyQualifiedName = false,
AllowMultipleValues = false
}
};
await graphAPIAuth.Sites[site.Id].Columns
.Request()
.AddAsync(columnDef);

The graph api doesn't currently support creating columns for any type fields other than plain text, I suggest you submit user voice to add support for other types of fields, I'll upvote for you.

Related

Not always a two way Related link in Azure DevOps using c#

I am creating a related link with the referenceName System.LinkTypes.Related in Azure DevOps programmatically using C# and Azure DevOps' SDK as below:
JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add(
new JsonPatchOperation
{
From = null,
Operation = Operation.Add,
Path = "/relations/-",
Value = new {
rel = "System.LinkTypes.Related",
url = $"https://dev.azure.com/{organization}/{projectName}/_workitems/edit/{relatedId}",
attributes = new
{
comment = $"Created programmatically on {DateTime.Now}."
}
}
}
);
await azureClient.UpdateWorkItemAsync(patchDoc, id, false, true, true, WorkItemExpand.All, cancellationToken: token);
The code above always created a two way link between id and relatedId.
But sometimes the link is one way!
How can i be sure to always create a link in both directions?

Use fields from a template DocuSign

I want to make a simple application C# with docusign.
I created a template on the site with several fields that the user will have to fill in. The application simply chooses the email address of the candidate.
I do like this for create my Envelope :
TemplateRole tRoleSigner = new TemplateRole();
tRoleSigner.Email = DSConfig.Signer1Email;
tRoleSigner.Name = DSConfig.Signer1Name;
tRoleSigner.RoleName = "Candidat";
TemplateRole tRoleCC = new TemplateRole();
tRoleCC.Email = DSConfig.Cc1Email;
tRoleCC.Name = DSConfig.Cc1Name;
tRoleCC.RoleName = "EnCopie";
List<TemplateRole> rolesList = new List<TemplateRole>() { tRoleSigner, tRoleCC };
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
{
EmailSubject = "Signatures des documents relatifs à une promesse d'embauche",
TemplateRoles = rolesList,
TemplateId = DSConfig.TemplateID,
Status = "sent"
};
I tested but the fields do not appear on the document ...
However if I directly use the template via docusign the fields are there!
I know that we can create a tab in the C # code but I want to use the fields defined on the site!
I think I'm missing something ...
Without more information, including logs and IDs can't be sure what is the issue.
Possibilities:
RoleName is wrong/mismatch. Must be the one in the template that you use the ID for.
Fields are using anchor tags that are not found in document.
Template is in production and you are using developer account.
You can also try the web app ("directly") again and enable to see the API logs. The web app uses the same API that you do, and this way you can see exactly how it's done.

Adding note to cell in google sheets c#

Is it possible to add notes to cells using Google? Apis.Sheets.v4?
It seems possible in python: Is it possible to use the Google Spreadsheet API to add a comment in a cell? but I've had no success duplicate it to c#, Insert a comment in a Google Sheet with google-sheets-api describes how to add it using an https call, but I would much rather use the google c# library than start sending HTTP calls myself if at all possible.
It would be a huge help if anyone know-how, or can point me towards a working example.
Thanks in advance.
Using Rafa Guillermos advice i got it to work.
public async void AddNote(string sheet, int column, int row, int sheetId, string noteMessage)
{
await Task.Delay(1);
var requests = new List<Request>();
// Grid range for a single cell, end column, and row have to be +1, otherwise, sheet throws error trying to write outside bounds.
var gridRange = new Google.Apis.Sheets.v4.Data.GridRange
{
EndColumnIndex = column + 1, StartColumnIndex = column, EndRowIndex = row + 1, StartRowIndex = row, SheetId = sheetId
};
// Building a request for update cells.
var request = new Google.Apis.Sheets.v4.Data.Request();
request.UpdateCells = new Google.Apis.Sheets.v4.Data.UpdateCellsRequest();
request.UpdateCells.Range = gridRange;
request.UpdateCells.Fields = "note";
request.UpdateCells.Rows = new List<Google.Apis.Sheets.v4.Data.RowData>();
request.UpdateCells.Rows.Add(new Google.Apis.Sheets.v4.Data.RowData());
request.UpdateCells.Rows[0].Values = new List<Google.Apis.Sheets.v4.Data.CellData>();
request.UpdateCells.Rows[0].Values.Add(new Google.Apis.Sheets.v4.Data.CellData());
request.UpdateCells.Rows[0].Values[0].Note = noteMessage;
requests.Add(request);
var requestBody = new Google.Apis.Sheets.v4.Data.BatchUpdateSpreadsheetRequest();
requestBody.Requests = requests;
var service = _authenticatorService.GetSheetsService(new[] { SheetsService.Scope.Spreadsheets} );
var batchRequest = service.Spreadsheets.BatchUpdate(requestBody, _spreadsheetId);
batchRequest.Execute();
}
_authenticatorService gives an authenticated sheet service to work with.
Answer:
In exactly the same way as python, you need to build your note as a batch request in C#.
Code Snippets:
You need to build your data request as list like:
List<Data.Request> requests = new List<Data.Request>();
and assign the values to the request body for the batch:
Data.BatchUpdateSpreadsheetRequest requestBody = new Data.BatchUpdateSpreadsheetRequest();
requestBody.Requests = requests;
before building the request object:
SpreadsheetsResource.BatchUpdateRequest request = sheetsService.Spreadsheets.BatchUpdate(requestBody, spreadsheetId);
and execute the request:
Data.BatchUpdateSpreadsheetResponse response = request.Execute();
More Information:
You can read about spreadsheets.batchUpdate here with a C# example code at the bottom of the page here.
A JSON representation of the request resource can be found here which follows the same structure as the answer you linked here.
References:
Sheets API v4 - spreadsheets.batchUpdate
Example code for spreadsheets.batchUpdate
Sheets API v4 - JSON Representation of Batch Request
Stack Overflow - Is it possible to use the Google Spreadsheet API to add a comment in a cell?

How do I add a structured ODBC data source to a tabular model using the AMO tabular library

Adding a structured ODBC data source to my model results in an error.
I want to generate a tabular model on a SQL Analysis Services server with compatibility level 1400 using the Microsoft.AnalysisServices.Tabular library using structured (ie. M / Power Query), non-legacy (ie. ProviderDataSource) data sources.
I installed the library using NuGet package Microsoft.AnalysisServices.retail.amd64 (16.3.0).
Here's my data source definition.
myDatabase.Model.DataSources.Add(new StructuredDataSource()
{
Name = "ODBC",
Description = "An structured ODBC data source definition",
ConnectionDetails = new ConnectionDetails()
{
Protocol = DataSourceProtocol.Odbc
},
Credential = new Credential()
{
AuthenticationKind = AuthenticationKind.UsernamePassword,
EncryptConnection = false,
Username = "MYUSERNAME",
Password = "MYPASSWORD"
}
}
When I run this code, I get:
COM error: Microsoft.Data.Mashup; The given data source reference is not a valid data source.
It doesn't give me any pointers where to look or what is wrong specifically. I suspected the definition needed a server address, but the address property of the ConnectionDetails object cannot be set according to the documentation.
ConnectionDetails.Address Property
Address of this connection. It can't be set, instead it should be modified directly.
When reviewing my question and off course further investigating the documentation, I constructed this solution. For those who struggle with the same problem, I figured it'd be nice to post it here.
Credential credential = new Credential()
{
AuthenticationKind = AuthenticationKind.UsernamePassword,
EncryptConnection = false,
Username = "MYUSERNAME",
Password = "MYPASSWORD" // Please note that this won't persist.
};
ConnectionDetails connectionDetails = new ConnectionDetails("{ 'protocol': 'odbc', 'address': { 'options': { 'dsn': 'MYODBCDSN' } }, 'authentication': null, 'query': null }");
dbWithDataSource.Model.DataSources.Add(new StructuredDataSource()
{
Name = "ODBC",
Description = "An ODBC structured (ie. non-legacy) data source definition",
ConnectionDetails = connectionDetails,
Credential = credential,
Options = new DataSourceOptions( "{ 'hierarchicalNavigation': true }" )
}
What I basically did, was pass in a JSON string in the ConnectionDetails constructor, setting the 'read-only' address property as well.

Retrive Wordoffsets for interim results

I am using the following config to retrieve results from the speech api:
StreamingConfig = new StreamingRecognitionConfig
{
Config = new RecognitionConfig
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 8000,
LanguageCode = languageCode,
EnableWordTimeOffsets = true
},
InterimResults = true
}
When retriving a result, the WordTimeOffsets should be included in the WordInfos of the property Alternatives.
Unfortunately, I am only getting WordInfos for results where IsFinal = true.
When retrieving interim results the array of words is empty although a transcript is there.
I have installed 1.1.0-beta02 from nuget and setup a .NET Core project.
I have read through the documentation and through some articles in the internet but found no hint that the wordinfos are only filled for final results.
Please let me know if you need some additional information.

Categories

Resources