SharePoint Column Types - sharepoint

I'm requesting SharePoint Columns using MS Graph and need to understand the type of each column.
Unfortunately, not all column types are support in Microsoft Graph. For example, Hyperlink or Picture (Url) types are not available. There is doesn't seem to be a way to look at a field has an unsupported type.
Are there plans to map all the types?
I've tried bot v1.0 APIs and beta APIs as well.
Request example:
https://graph.microsoft.com/beta/groups/group-id/sites/root/columns
for, let's say, Text field I see field property:
"text": {
"allowMultipleLines": false,
"appendChangesToExistingText": false,
"linesForEditing": 0,
"maxLength": 255
}
But for Url, or Taxonomy, and some other types there is no indication at all.

In currently, the Graph API can provide the type property of the ColumnDefinition resource.
Check the official document here: ColumnDefinition resource.
As a workaround, we have to use SharePoint REST API to achieve it.
https://tenant.sharepoint.com/sites/lz/_api/web/Fields

Related

Filtering by file type or name in Microsoft Graph API

If I want to find just image files using the Microsoft Graph API. Is there a way to filter using $filter? By file type or name "endswith"?
I try
https://graph.microsoft.com/v1.0/sites/{MyID}.sharepoint.com/lists/{Drive ID}/items?$filter=endswith(webUrl, '.png')
but got this error
"message": "Item not found",
but there is an image (.png) file contain in the drive
, My goal is to get response all of image file that contain in Drive in Sharepoint
Yeah, I agree that there is no name property populated in the response even if its documented here that there is a name property. And all properties doesn't support all ODATA query parameters as far as I know.
But you can do one thing. There is a fields relationship which you can use to get the filename with extension. Use the query below.
https://graph.microsoft.com/v1.0/sites/soaadteam.sharepoint.com/lists/8f7fc3c2-8d9b-4563-94c8-b63bf0f19ebc/items?$expand=fields
Pick that LinkFilename property from fields property and you can filter it on your end(by writing code) easily.

How To Retrieve Custom Columns For DriveItems in MS Graph

I'm trying to use the Graph API to retrieve a hierarchy of files in a Sharepoint document library. Since document libraries are stored in "drives" (is it technically correct to call it OneDrive?), I'm using the /drives endpoint to fetch a list of files, like this:
https://graph.microsoft.com/beta/drives/{driveid}/root/children
I would like to get information from some of the custom columns that exist when viewing these items through Sharepoint. Using ?expand=fields doesn't work because fields only exists in listItem object of the /sites endpoint, not in the driveItem object of /drives endpoint. If I try obtaining the listItem from a single driveItem (traversing the Graph from OneDrive to Sharepoint), and then expanding the fields, like
https://graph.microsoft.com/beta/drives/{driveid}/items/{driveItemId}/listItem?expand=fields
this retrieves built-in columns (Author, DocIcon, and some others) but doesn't seem to retrieve the custom columns.
I've also tried getting the list of files from the /sites endpoint, and using ?expand=fields will get the custom columns, but it gets every file from every subfolder, rather than the current folder path. But I feel that deserves its own SO question.
Is it possible to retrieve custom column information from driveItems?
I spent a lot of time digging around with the different syntax possibilities and was finally able to get custom library properties using this query format. This is the only one that has produced my custom/user-defined fields for a document library.
https://graph.microsoft.com/v1.0/drives/insert_drive_id_here/root/children?expand=listItem
Shortened result:
{
"#odata.context": "...",
"value": [
{
"#microsoft.graph.downloadUrl": "...",
"listItem#odata.context": "...",
"listItem": {
"#odata.etag": "...",
"fields#odata.context": "...",
"fields": {
"#odata.etag": "...",
"Title": "...",
"Other_Custom_Property": "..."
}
}
}
]
}
I did some testing. What SHOULD work is:
https://graph.microsoft.com/beta/drives/{driveid}/root/children?$select=id,MyCustomColumnName
However, when I did that, it just returned that id field. In my opinion, that is a bug in the graph because this same type of query does work in the SharePoint REST api.
If this helps, you can accomplish this by using the SharePoint REST api. Your endpoint query would be something like:
https://{yoursite}.sharepoint.com/sites/{sitename}/_api/web/lists/(' {DocumentLibraryID}')/items?$select=id,MyCustomColumnName
There are other ways to do the same query.
Try the list endpoint then expand driveItem and fields. You now have both custom column fields and drive item fields.
/beta/sites/[site-id]/lists/[list-id]/items?expand=driveitem,fields&filter=(fields/customColumn eq 'someValue')

How to remove a reference of task details with an external reference in planner using the beta Microsoft Graph API

I'm newbie to the Microsoft Graph API and I want to use it to remove a reference (link) of a task details in planner.
As part of the updating a task details I use the externalReferenceCollection and to perform the update I follow the link below: http://graph.microsoft.io/en-us/docs/api-reference/beta/api/taskdetails_update
Documentation from Microsoft also says that: "Properties of an Open Type can be defined by the client. In this case, the client must provide valid URLs based on the HTTP/HTTPS protocols as properties and their values must be the externalReference objects. Based on OData, property names in Open Types cannot contain the following characters: ., :, % so they need to be encoded. Example is shown above. To remove a reference, set the value of the property to null"
But I'm not sure how to set the value of property to null to build up a JSON string to remove a reference (link) of a task details.
PS: I'm using HttpClient in C# and the way to update a task details is similar to this class: https://github.com/OfficeDev/TrainingContent/blob/master/O3653/O3653-15%20Microsoft%20Graph%20for%20Planner%20and%20Tasks/Completed%20Solutions/Exercise3/Office365PlannerTask/Office365PlannerTask/Models/MyTasksRepository.cs
Thanks in advance!
Tuan
Finally, I've figured out the answer. I post here so it should help.
To remove a reference with the url is "http%3A//2%2Eff%2E2%2E1" for instance, the request body JSON of the references should look like as below:
{"description": "task description 1", "references": {
"http%3A//2%2Eff%2E2%2E1": null
}}
Happy coding!

Google Freebase Search API Alternative?

Google deprecated their Freebase Search API, and is transferring things over to Wikidata, however there appears to be no replacement for their Freebase Search API (https://developers.google.com/freebase/v1/search-overview) that:
Autosuggesting entities (e.g. Freebase Suggest Widget)
Getting a ranked list of the most notable entities with a given name.
Finding entities using Search Metaschema.
Moreover, it would also take in malformed strings and correct them, and return nice detailed relevancy rankings, along with the associated freebase topic id. I can't find anything in their Custom Search API that returns any information relevant to their, or any other knowledge graph.
Ideally would like something that I can query similar to this and returns a result like they used to:
For example, a query of "Nirvana" in the Freebase Search API would return:
{
"status":"200 OK",
"result":[
{
"mid":"/m/0b1zz",
"name":"Nirvana",
"notable":{"name":"Record Producer","id":"/music/producer"},
"score":55.227268
},{
"mid":"/m/05b3c",
"name":"Nirvana",
"notable":{"name":"Belief","id":"/religion/belief"},
"score":44.248726
},{
"mid":"/m/01h89tx",
"name":"Nirvana",
"notable":{"name":"Musical Album","id":"/music/album"},
"score":30.371510
},{
"mid":"/m/01rn9fm",
"name":"Nirvana",
"notable":{"name":"Musical Group","id":"/music/musical_group"},
"score":30.092449
},{
"mid":"/m/02_6qh",
"name":"Nirvana",
"notable":{"name":"Film","id":"/film/film"},
"score":29.003593
},{
"mid":"/m/01rkx5",
"name":"Nirvana Sutra",
"score":21.344824
}
],
"cost":10,
"hits":0
}
Note the relevance, and Freebase mid.
Essentially are there any alternatives out there, either open source, or commercial that replaces this much needed functionality?
I've used the Prismatic Interest graph API for somewhat similar functionality. My use-case was a bit different (tagging documents with topics) but looking at their API endpoints you might be able to duplicate the functionality you described above with a query to topic/search (search for topics that match a search string) and a query to topic/topic to search for similar topics (sorted by score).
Edit
As David notes in the comments below, the Prismatic Interest Graph API has been discontinued.
Also, the Google Knowledge Graph Search API now seems to be the intended replacement for the Freebase Search API.
How about the Google Knowledge Graph Search API? There is also a web application exposing the API.
The :BaseKB project offers Freebase data (plus some other data) as RDF. :BaseKB's data can be downloaded for free or easily run on an AWS instance for live queries. The AWS machine image contains a Virtuoso database so you can query it with the SPARQL query language.

What are valid SPAlert EventTypeBitmask values?

According to many blogs on the internet when creating a SharePoint alert (SPAlert) from code you have to specify values for both the EventType and the EventTypeBitmask. However, I cannot find any explanation about the values of EventTypeBitmask. I created some alerts using the SharePoint web GUI and inspected the EventTypeBitmask values of the created alerts. But they don't seem to make much sense.
Does anybody know which values should be used?
With the help of Reflector, the recognised values for EventTypeBitmask are defined by this enum:
public enum AlertChangeType
{
Discovered = 1,
Modified = 2
}
According to the documentation, the behaviour is All (0xffffffff) if not specified.
As this enum is undocumented, derive from it what you can. My guess is that Discovered means new items and Modified means changed items.

Resources