The object model of the client. How to get instance id

So, on my sharepoint site content page, I have an application. Can someone tell me how to get the instance id. so that I can call the link:

http://testingwebcompany.sharepoint.com/_layouts/15/appredirect.aspx?instance_id= {<>}

I cannot get it when I search for ClientContext.Web.Lists.

thanks

+4
source share
2 answers

I got it, it seems that the instance id is automatically generated. the real application URL is when going through ClientContext.Web.Webs []. title == "Application Name" and then extracting ClientContext.Web.Webs []. Url.

0
source

The following example shows how to get the application by its name

public static class WebExtensions { public static IEnumerable<AppInstance> GetAppInstanceByTitle(this Web web,string appTitle) { var ctx = web.Context; var apps = AppCatalog.GetAppInstances(ctx, web); var result = ctx.LoadQuery(apps.Where(a => a.Title == appTitle)); return result; } } 

Using

 using (var ctx = new ClientContext(webUri)) { var appTitle = "\"Napa\" Office 365 Development Tools"; var result = ctx.Web.GetAppInstanceByTitle(appTitle); ctx.ExecuteQuery(); var app = result.FirstOrDefault(); if (app != null) Console.WriteLine(app.Id); // print App Instance Id } 
0
source

Source: https://habr.com/ru/post/1488419/


All Articles