Retrieving thumbnail path from portal item

508
1
Jump to solution
04-18-2022 08:20 AM
TomGeo
by
Occasional Contributor III

I want to retrieve the thumbnail path of a layer at our enterprise portal, and while that is straight forward I have the challenge, that I cannot use the path returned

https://our-portal.com/portal/sharing/rest/content/items/580d1a480196436fb7e2e1170466ba94/info/thumbnail/thumbnail1548171039005.png

 

Because there I am getting an Error 403 (You do not have permissions to access this resource or perform this operation.).

The layer itself I can create using

string curService = $"https://our-portal.com/portal/home/item.html?id={guid}";
await QueuedTask.Run(() => LayerFactory.Instance.CreateLayer(new Uri(curService, UriKind.Absolute), activeMapView.Map, 0));

 

How can I connect to the thumbnail?

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
1 Solution

Accepted Solutions
TomGeo
by
Occasional Contributor III

The solution to get to the thumbnail is to add the token of your current session to the thumbnail path.

ArcGISPortal activePortal = ArcGISPortalManager.Current.GetActivePortal();
string sessionToken = activePortal.GetToken();
_thumbnail = $"{portalItem.ThumbnailPath}?token={_portalToken}";

 

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!

View solution in original post

0 Kudos
1 Reply
TomGeo
by
Occasional Contributor III

The solution to get to the thumbnail is to add the token of your current session to the thumbnail path.

ArcGISPortal activePortal = ArcGISPortalManager.Current.GetActivePortal();
string sessionToken = activePortal.GetToken();
_thumbnail = $"{portalItem.ThumbnailPath}?token={_portalToken}";

 

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos