I know that URL parameters are created by setting /:paramName variables after the path in the Page Configuration screen, however is it possible to pass a dictionary as a URL Paramater?
Other things I have seen online typically take this format ?Val1=1&Val2=3 that equates to /{"Val1":1,"Val2":3}
When I try this though it just renders as a string, I know that I could write a script to unpack that dictionary format into a python dictionary, but I am looking for something more native.
Any ideas?
Note: I have a strong feeling this isnt currently possible, and will be a feature request, if so I already made an ideas post here.
FWIW, I still cannot log in to the ideas portal. After an attempt, IAâs SSO just redirects back to canny.io, but canny.io doesnât recognized the login status. Still using a third-party cookie, I presume, instead of a properly secure backend handoff.
Well, I have ticket 111942 âin progressâ (from January) with a comment from Adam that canny.ioâs new non-third-party-cookie authentication support was being implementedâŚ
Oh. Short answer: no, because the url is just a String. You could string-ify your object for passing through the url, and then expect a string for the param, with a separate custom object which converts it into an object through a binding transform. OR you could have basic value params, and then bind a custom objectâs internal values to the view params.
This is what I did as a workaround for now, and I have a script that converts the /Val1=1&Val2=3 format into a dictionary on a custom property.
It just didnt feel like the most scalable way for the future, especially considering you can have Object parameters, it would be nice to be able to utilize those through the URL in some format as well (same with list, but in the meanwhile you could probably do that with /1,2,3,4 parsing into [1,2,3,4])
For prosperities sake though, here is the Ideas post for anyone that runs into this same question
Anything passed through the URL can ONLY be a string. If you absolutely MUST pass something like a dictionary, youâre better off using a Session Property and binding the relevant View values to that.
Perspectiveâs parameter model is built only on the URL path, where parts of the path are substitutions. Is there any possibility of exposing the pageâs actual query parameters from the underlying request object? Yeah, I know it is probably complicated by WebSockets, butâŚ
(Havenât dug under the hood to figure it out myselfâtoo freaking busy.)
Codyâs answer is correct - because pages are defined by their URL, and URLs are just strings, at some point, itâs got to be a string. Even if we were to support some sort of ?param=val style parameter passing, all this would do is open up a page to accepting variable numbers of params, not actual dictionary objects, because again, itâs just a string.
Also, the URLs are mostly a fiction because Perspective is a single-page-app. Beyond the initial http request, there are no more requests from there on out - as you navigate, we just manipulate the URL for you so it looks like youâre navigating in the traditional sense. But the intent of the model is that as you navigate around your pages, the URL is bookmarkable - if you were to land on that URL, it would bring you back to the same place in the app.
You could avoid this by simply eschewing the mounted page system entirely, and just manipulate mounted views & their parameters directly. The downside is that youâd lose the bookmark-ability of navigation and to a user, the app would appear to be all one un-changing URL.
I ended up going the route of encoding the URLs in a way that i can decode back into a dictionary for this use case.
For anyone that wants the scripts here they are
# This takes a dictionary of parameters and converts it into a URL parameter string
def dictionaryToURLParameter(params):
import urllib
paramList = []
for key, value in params.items():
try: key = urllib.quote(key)
except: key = key
try: value = urllib.quote(value)
except: value = value
paramList.append("%s=%s" % (key, value))
# Replace any slashes with pipes so that the perspective URL parser doesnt fail to understand the text
return "&".join(paramList).replace('/', '|')
# This takes a URL parameter string and converts it into a dictionary of parameters
def URLStringToDictionary(paramString):
import urllib
# Replace any pipes with slashes so that the perspective URL parser doesnt fail to understand the text
paramString = urllib.unquote(paramString.replace('|', '/'))
params = {}
for pair in paramString.split('&'):
pair = pair.split('=')
params[pair[0]] = pair[1]
return params
In the entry field where it asks for a callback URL, could you enter it with the default / at the end like so: ignition.com/data/client/perspective/MyProject/
that way it ends up as ignition.com/data/client/perspective/MyProject/?code=xxx&scope=yyy
Defining the url parameter should have the colon after the slash like /page/:code
You shouldnât have to bind the label text to anything similar to /:code because that url parameter translates to view.params.code which is where you should be binding it
Itâs weird to see your label acting the way it is, because I use question marks in my parameters and it doesnât care, let me know if anything above fixes it