Select to view content in your preferred language

Share button in a Collection produces mini URL that does not work, long copy/pasted Link works.

1123
4
01-16-2024 06:20 PM
GregoryLund2
Occasional Contributor

My students have created ArcGIS Online Collections, and have been directed to use the 'Share' icon to create a short url for their collection, to add to their Resume, etc.

share.png

This example produces this link: https://arcg.is/1PnLfX

Which results in this 'error':

error.png

At first I thought it was the permissions, but when I copy the students 'Long URL' from the Collection:

https://storymaps.arcgis.com/collections/566bdc6433f94e1caf9761b418ce4f54

It works perfectly fine.

All this was done using Mozilla Firefox, latest edition. 121.0.1 64 Bit on Windows 11.

Also Tried in the latest version of Chrome.

(IE and 'Edge' are not installed on my machine... because... why would they be?)

Saving/Re-saving, shutting down, etc. didn't work.

I tried searching for a solution but didn't find any.

Thanks for the help.

<EDIT> It should be noted that this only happened to 15% of my students, the rest worked</EDIT>

Regards,

Gregory Lund

0 Kudos
4 Replies
RhettZufelt
MVP Notable Contributor

Don't know the solution to the collections share link, but you can always run the same utility it is 'supposed' to use and generate a valid short url.

https://arcg.is/prod/shorten?longUrl=https://storymaps.arcgis.com/collections/566bdc6433f94e1caf9761b418ce4f54

Generates:
{"status_code": 200, "status_txt": "OK", "data": { "long_url" : "https://storymaps.arcgis.com/collections/566bdc6433f94e1caf9761b418ce4f54", "url": "https://arcg.is/1rX0iK", "hash": "1rX0iK", "global_hash": "1rX0iK", "new_hash": 0 } }

And this part of it is the short link:

https://arcg.is/1rX0iK

Just put the long URL after the longUrl= and submit.  the short URL is after the "url:"

 

R_

GregoryLund2
Occasional Contributor

R_,

Great idea, I'll give this a try.
Still hoping to hear the diagnosis of the main issue, but this is a good fix (along with using the Long (copy/paste) URL, or bitly, for that matter.

Gregory

0 Kudos
ODWC_GIS
Frequent Contributor

I was running into something similar yesterday, but still haven't narrowed down the issue besides something about how the long url gets its characters encoded before being submitted to the arcg.is ESRI shortener.  Still trying to figure it out, since the long url is very long.

0 Kudos
ODWC_GIS
Frequent Contributor

@GregoryLund2 

Alright, in my case the error seemed to be the degree to which the long URL was encoded with Hex values.  So, my solution is unlikely to affect your situation.

I kept running into issues with just how much of a url needed to be encoded before passing it to the longUrl parameter to return a working link.

 

 

newurl="https://arcg.is/prod/shorten?longUrl=" 
import urllib.request as openurl
import urllib.parse 
import urllib.request as request
import json

# xy, yy, and ss are dynamic variables for the x,y,& scale of a viewer
# ExB is the first part of an Experience Builder app URL ending in ",center:"

fullurl=ExB+xy+"%2C"+yy+"%2C102100,scale:"+ss

encfull=urllib.parse.quote(fullurl)
thisn=newurl+encfull
req=request.Request(thisn)
response = urlopen.urlopen(req)
response_bytes=response.read()

xy=response_bytes.decode('UTF-8')
xyz=json.loads(xy)
shorturl=xyz["data"]["url"]

 

 

     What I found unusual was that the information within any single "URL Parameter" had to be fully encoded, or the initial unencoded long url (fullurl, but with actual commas replacing each of the "%2C"s) wouldn't work as a valid link when mouse-clicked.

     Passing that fullurl to the urllib.parse.quote() would return a string wherein the forward-slashes, underscores, negative marks, and decimals were preserved.  Sending that response on to the longUrl parameter in the arcg.is shortener then returned a valid short-link.

https://arcg.is/CKqC9
was returned after passing the following to the longUrl:
https%3A//experience.arcgis.com/experience/26144eb0a1794981a85aa1802a079448/%23widget_6%3Dactive_datasource_id%3AdataSource_1%2Ccenter%3A-10753596.352663983%252C4075935.9964008047%252C102100%2Cscale%3A53740.0
0 Kudos