so I'm working on SharePoint Online integration using MS Graph. My issue is the way MS Graph present field values for hyperlinks. I'm not too sure how to handle the parsing of these dynamic fields. Please see below code snippets.
The MS Graph JSON response for SharePoint list fields:
"fields": {
"@odata.etag": "\"54e4e975-d364-4064-a2f0-63172bd74836,13\"",
"FileLeafRef": "FILENAMEBOYS.jpg",
"Title": "Trees",
"Column_x0020_For_x0020_Text_x0020_Testing": "awdada",
"link": {
"Description": "https://stackoverflow.com/questions/ask",
"Url": "https://stackoverflow.com/questions/ask"
},
"YES_x0020_OR_x0020_NO": true,
"id": "1",
"ContentType": "Document",
"Created": "2018-06-28T16:57:34Z",
"AuthorLookupId": "6",
"Modified": "2018-07-19T13:59:12Z",
"EditorLookupId": "6",
"_CheckinComment": "",
"LinkFilenameNoMenu": "FILENAMEBOYS.jpg",
"LinkFilename": "FILENAMEBOYS.jpg",
"DocIcon": "jpg",
"FileSizeDisplay": "1048862",
"ItemChildCount": "0",
"FolderChildCount": "0",
"_ComplianceFlags": "",
"_ComplianceTag": "",
"_ComplianceTagWrittenTime": "",
"_ComplianceTagUserId": "",
"_CommentCount": "",
"_LikeCount": "",
"Edit": "0",
"_UIVersionString": "12.0",
"ParentVersionStringLookupId": "1",
"ParentLeafNameLookupId": "1"
}
You'll see in the above snippet, the field named Link is JSON, but the result of the other field values are just normal strings. So I currently use IDictionary<string, object> to parse the data, due to the fact that I'm not sure what the field value will hold.
Now when I bind my IDictionary field collection to my data grid, I get the below result. (As expected, cause Link has not been properly parsed. Just thrown to type Object.)
Q : I'm not too sure how to go about parsing the values to enable me to bind directly to the hyperlink URL. Should I be doing some kind of a TryParse to check if it's a hyperlink (or any other kind of expected result type) before parsing and storing it as a object.
Just to add to the above, the column JSON result for Hyperlink columns has no indication what type it is. Added the columns JSON below as refrence.
The MS Graph JSON response for SharePoint list column LINK:
{
"columnGroup": "Custom Columns",
"description": "",
"displayName": "link",
"enforceUniqueValues": false,
"hidden": false,
"id": "97a58edb-1f5c-4e46-b843-fc9827847088",
"indexed": false,
"name": "link",
"readOnly": false,
"required": false
}
