Home

MS Teams Graph API support to open files in-app

%3CLINGO-SUB%20id%3D%22lingo-sub-860641%22%20slang%3D%22en-US%22%3EMS%20Teams%20Graph%20API%20support%20to%20open%20files%20in-app%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-860641%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EMS%20Graph%20has%20provided%20an%20API%20support%20to%20open%20files%20by%20hitting%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fdriveitem-preview%3Fview%3Dgraph-rest-1.0%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%2Fpreview%3C%2FA%3E%20API.%3C%2FP%3E%3CP%3EThe%20parameters%20that%20the%20API%20expects%20are%20in%20the%20context%20of%20Files%20since%20the%20expected%20parameter%20%3CEM%3Eitem-id%3C%2FEM%3E%20is%20available%20only%20when%20we%20hit%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fdriveitem-list-children%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%2Fchildren%3C%2FA%3E%20API%20and%20the%20same%20id%20for%20the%20same%20attachment%20is%20not%20available%20when%20we%20fetch%20conversation%20by%20hitting%20%2FgetConversations.%3C%2FP%3E%3CDIV%3EWe%20plan%20to%20match%20the%20%3CSTRONG%3E%3CEM%3Ee-tag%3C%2FEM%3E%3C%2FSTRONG%3E%20value%20and%20the%20%3CSTRONG%3E%3CEM%3Eattachment-id%3C%2FEM%3E%3C%2FSTRONG%3E%20in%20absence%20of%20any%20API%20to%20map%20both%20the%20responses%20to%20get%20%3CSTRONG%3E%3CEM%3Eitem-id%3C%2FEM%3E%3C%2FSTRONG%3E%3F%20Does%20that%20look%20correct%20from%20the%20implementation%20perspective%3F%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EAlso%20Can%20anyone%20suggest%20if%20there%20is%20another%20API%20to%20open%20files%20when%20we%20do%20not%20have%20the%20%3CEM%3Eitem-id%3C%2FEM%3E%20with%20us%3F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EResponse%20of%20%2FgetConversations%20with%20attachment%20details%3C%2FEM%3E%3CEM%3E%20%3A%3C%2FEM%3E%3C%2FP%3E%3CPRE%3E%3CEM%3E%22attachments%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22id%22%3A%20%225c5c0073-c98a-4a9f-9a24-429cbda7f2c4%22%2C%3CBR%20%2F%3E%22contentType%22%3A%20%22reference%22%2C%3CBR%20%2F%3E%22contentUrl%22%3A%20%22https%3A%2F%2Foptytenant.sharepoint.com%2Fsites%2FFilesTeams%2FShared%20Documents%2FTrial%20Delta%20Channel%2FUse%20cases.rtf%22%2C%3CBR%20%2F%3E%22content%22%3A%20null%2C%3CBR%20%2F%3E%22name%22%3A%20%22Use%20cases.rtf%22%2C%3CBR%20%2F%3E%22thumbnailUrl%22%3A%20null%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%26nbsp%3B%3C%2FEM%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResponse%20of%20%2Fchildren%20with%20file%20details%20%3A%26nbsp%3B%3C%2FP%3E%3CPRE%3E%22value%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22%40microsoft.graph.downloadUrl%22%3A%20%22https%3A%2F%2Foptytenant.sharepoint.com%2Fsites%2FFilesTeams%2F_layouts%2F15%2Fdownload.aspx%3FUniqueId%3D5c5c0073-c98a-4a9f-9a24-429cbda7f2c4%26amp%3BTranslate%3Dfalse%26amp%3Btempauth%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJh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Z3JvdXAud3JpdGUgYWxsc2l0ZXMuZnVsbGNvbnRyb2wgYWxsc2l0ZXMubWFuYWdlIGFsbHNpdGVzLnJlYWQgYWxsc2l0ZXMud3JpdGUgYWxscHJvZmlsZXMucmVhZCBhbGxwcm9maWxlcy5yZWFkIGFsbHByb2ZpbGVzLndyaXRlIiwidHQiOiIyIiwidXNlUGVyc2lzdGVudENvb2tpZSI6bnVsbH0.amdxOU5HYXlSQXo0dGpwZHhVWVdNMmRZOUJoYVQwbU0yTFE2UjJud2ErOD0%26amp%3BApiVersion%3D2.0%22%2C%3CBR%20%2F%3E%22createdDateTime%22%3A%20%222019-09-13T12%3A15%3A21Z%22%2C%3CBR%20%2F%3E%22eTag%22%3A%20%22%5C%22%7B5C5C0073-C98A-4A9F-9A24-429CBDA7F2C4%7D%2C2%5C%22%22%2C%3CBR%20%2F%3E%22id%22%3A%20%2201243ZUBDTABOFZCWJT5FJUJCCTS62P4WE%22%2C%3CBR%20%2F%3E%22lastModifiedDateTime%22%3A%20%222019-09-13T12%3A15%3A22Z%22%2C%3CBR%20%2F%3E%22name%22%3A%20%22Use%20cases.rtf%22%2C%3CBR%20%2F%3E%22webUrl%22%3A%20%22https%3A%2F%2Foptytenant.sharepoint.com%2Fsites%2FFilesTeams%2F_layouts%2F15%2FWopiFrame.aspx%3Fsourcedoc%3D%257B5C5C0073-C98A-4A9F-9A24-429CBDA7F2C4%257D%26amp%3Bfile%3DUse%2520cases.rtf%26amp%3Baction%3Ddefault%22%2C%3CBR%20%2F%3E%22cTag%22%3A%20%22%5C%22c%3A%7B5C5C0073-C98A-4A9F-9A24-429CBDA7F2C4%7D%2C2%5C%22%22%2C%3CBR%20%2F%3E%22size%22%3A%20738%2C%3CBR%20%2F%3E%22createdBy%22%3A%20%7B%3CBR%20%2F%3E%22application%22%3A%20%7B%3CBR%20%2F%3E%22id%22%3A%20%22cc15fd57-2c6c-4117-a88c-83b1d56b4bbe%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22Microsoft%20Teams%20Services%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22user%22%3A%20%7B%3CBR%20%2F%3E%22email%22%3A%20%22demo%40optytenant.onmicrosoft.com%22%2C%3CBR%20%2F%3E%22id%22%3A%20%22f97d501b-e78c-412a-a1da-6dd3d486c364%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22John%20Doe%20(Optymyze)%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22lastModifiedBy%22%3A%20%7B%3CBR%20%2F%3E%22application%22%3A%20%7B%3CBR%20%2F%3E%22id%22%3A%20%225e3ce6c0-2b1f-4285-8d4b-75ee78787346%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22Microsoft%20Teams%20Web%20Client%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22user%22%3A%20%7B%3CBR%20%2F%3E%22email%22%3A%20%22demo%40optytenant.onmicrosoft.com%22%2C%3CBR%20%2F%3E%22id%22%3A%20%22f97d501b-e78c-412a-a1da-6dd3d486c364%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22John%20Doe%20(Optymyze)%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22parentReference%22%3A%20%7B%3CBR%20%2F%3E%22driveId%22%3A%20%22b!f3f5WRkLQkiSLcq48RHX0Qy05YkLX09GuSOBNZG3-JGtxSZLMJdnQ59Rd0xW3mWK%22%2C%3CBR%20%2F%3E%22driveType%22%3A%20%22documentLibrary%22%2C%3CBR%20%2F%3E%22id%22%3A%20%2201243ZUBDPOTRB6TYVDNFIE2YDAYKT5YBO%22%2C%3CBR%20%2F%3E%22path%22%3A%20%22%2Fdrives%2Fb!f3f5WRkLQkiSLcq48RHX0Qy05YkLX09GuSOBNZG3-JGtxSZLMJdnQ59Rd0xW3mWK%2Froot%3A%2FTrial%20Delta%20Channel%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22file%22%3A%20%7B%3CBR%20%2F%3E%22mimeType%22%3A%20%22application%2Frtf%22%2C%3CBR%20%2F%3E%22hashes%22%3A%20%7B%3CBR%20%2F%3E%22quickXorHash%22%3A%20%22XmcM1Y3bsieJcbf6JmmMviOoEVU%3D%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22fileSystemInfo%22%3A%20%7B%3CBR%20%2F%3E%22createdDateTime%22%3A%20%222019-09-13T12%3A15%3A21Z%22%2C%3CBR%20%2F%3E%22lastModifiedDateTime%22%3A%20%222019-09-13T12%3A15%3A22Z%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-860641%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBest%20Practices%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EConversations%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFiles%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHow-to%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETips%20%26amp%3B%20Tricks%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Contributor

Hi,

MS Graph has provided an API support to open files by hitting /preview API.

The parameters that the API expects are in the context of Files since the expected parameter item-id is available only when we hit /children API and the same id for the same attachment is not available when we fetch conversation by hitting /getConversations.

We plan to match the e-tag value and the attachment-id in absence of any API to map both the responses to get item-id? Does that look correct from the implementation perspective?

 

Also Can anyone suggest if there is another API to open files when we do not have the item-id with us?

 

Response of /getConversations with attachment details :

"attachments": [
{
"id": "5c5c0073-c98a-4a9f-9a24-429cbda7f2c4",
"contentType": "reference",
"contentUrl": "https://optytenant.sharepoint.com/sites/FilesTeams/Shared Documents/Trial Delta Channel/Use cases.rtf",
"content": null,
"name": "Use cases.rtf",
"thumbnailUrl": null
}

 

Response of /children with file details : 

"value": [
{
"@microsoft.graph.downloadUrl": "https://optytenant.sharepoint.com/sites/FilesTeams/_layouts/15/download.aspx?UniqueId=5c5c0073-c98a-4a9f-9a24-429cbda7f2c4&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvb3B0eXRlbmFudC5zaGFyZXBvaW50LmNvbUA5ZDliYzliMS1mNzhjLTRjMTEtYTk4Mi05Mzk0YzI0MzYxY2IiLCJpc3MiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAiLCJuYmYiOiIxNTY4NjE5MzkzIiwiZXhwIjoiMTU2ODYyMjk5MyIsImVuZHBvaW50dXJsIjoiMk5kWk5aVFBGRnhpT05UTXRnTmliRjAwM3N4ZnZWS3QwYlZPK05HNlRWND0iLCJlbmRwb2ludHVybExlbmd0aCI6IjEzOCIsImlzbG9vcGJhY2siOiJUcnVlIiwiY2lkIjoiTldZNVpUSXpaRFl0WkdVd1lpMDBNMkU0TFdFellqa3RPRFV6TVRGaVptUXdaRGN5IiwidmVyIjoiaGFzaGVkcHJvb2Z0b2tlbiIsInNpdGVpZCI6Ik5UbG1PVGMzTjJZdE1HSXhPUzAwT0RReUxUa3lNbVF0WTJGaU9HWXhNVEZrTjJReCIsImFwcF9kaXNwbGF5bmFtZSI6InRlYW1zZGVtbyIsImdpdmVuX25hbWUiOiJKb2huIiwiZmFtaWx5X25hbWUiOiJEb2UiLCJhcHBpZCI6IjdjMGVjOTkzLTU5NTktNDc1Zi04Yjk5LWVhMWEwMjViZmUxMSIsInRpZCI6IjlkOWJjOWIxLWY3OGMtNGMxMS1hOTgyLTkzOTRjMjQzNjFjYiIsInVwbiI6ImRlbW9Ab3B0eXRlbmFudC5vbm1pY3Jvc29mdC5jb20iLCJwdWlkIjoiMTAwMzIwMDAzMkRDNjdCMCIsImNhY2hla2V5IjoiMGguZnxtZW1iZXJzaGlwfDEwMDMyMDAwMzJkYzY3YjBAbGl2ZS5jb20iLCJzY3AiOiJteWZpbGVzLnJlYWQgYWxsZmlsZXMucmVhZCBteWZpbGVzLndyaXRlIGFsbGZpbGVzLndyaXRlIGdyb3VwLnJlYWQgZ3JvdXAud3JpdGUgYWxsc2l0ZXMuZnVsbGNvbnRyb2wgYWxsc2l0ZXMubWFuYWdlIGFsbHNpdGVzLnJlYWQgYWxsc2l0ZXMud3JpdGUgYWxscHJvZmlsZXMucmVhZCBhbGxwcm9maWxlcy5yZWFkIGFsbHByb2ZpbGVzLndyaXRlIiwidHQiOiIyIiwidXNlUGVyc2lzdGVudENvb2tpZSI6bnVsbH0.amdxOU5HYXlSQXo0dGpwZHhVWVdNMmRZOUJoYVQwbU0yTFE2UjJud2ErOD0&ApiVersion=2.0",
"createdDateTime": "2019-09-13T12:15:21Z",
"eTag": "\"{5C5C0073-C98A-4A9F-9A24-429CBDA7F2C4},2\"",
"id": "01243ZUBDTABOFZCWJT5FJUJCCTS62P4WE",
"lastModifiedDateTime": "2019-09-13T12:15:22Z",
"name": "Use cases.rtf",
"webUrl": "https://optytenant.sharepoint.com/sites/FilesTeams/_layouts/15/WopiFrame.aspx?sourcedoc=%7B5C5C0073-C98A-4A9F-9A24-429CBDA7F2C4%7D&file=Use%20cases.rtf&action=default",
"cTag": "\"c:{5C5C0073-C98A-4A9F-9A24-429CBDA7F2C4},2\"",
"size": 738,
"createdBy": {
"application": {
"id": "cc15fd57-2c6c-4117-a88c-83b1d56b4bbe",
"displayName": "Microsoft Teams Services"
},
"user": {
"email": "demo@optytenant.onmicrosoft.com",
"id": "f97d501b-e78c-412a-a1da-6dd3d486c364",
"displayName": "John Doe (Optymyze)"
}
},
"lastModifiedBy": {
"application": {
"id": "5e3ce6c0-2b1f-4285-8d4b-75ee78787346",
"displayName": "Microsoft Teams Web Client"
},
"user": {
"email": "demo@optytenant.onmicrosoft.com",
"id": "f97d501b-e78c-412a-a1da-6dd3d486c364",
"displayName": "John Doe (Optymyze)"
}
},
"parentReference": {
"driveId": "b!f3f5WRkLQkiSLcq48RHX0Qy05YkLX09GuSOBNZG3-JGtxSZLMJdnQ59Rd0xW3mWK",
"driveType": "documentLibrary",
"id": "01243ZUBDPOTRB6TYVDNFIE2YDAYKT5YBO",
"path": "/drives/b!f3f5WRkLQkiSLcq48RHX0Qy05YkLX09GuSOBNZG3-JGtxSZLMJdnQ59Rd0xW3mWK/root:/Trial Delta Channel"
},
"file": {
"mimeType": "application/rtf",
"hashes": {
"quickXorHash": "XmcM1Y3bsieJcbf6JmmMviOoEVU="
}
},
"fileSystemInfo": {
"createdDateTime": "2019-09-13T12:15:21Z",
"lastModifiedDateTime": "2019-09-13T12:15:22Z"
}
}
]

 

 

Related Conversations