I’m writing an API and would like people to be able to supply a Google Charts API call as an argument. What’s the proper way to deconstruct this problematic API call, where an argument contains an entirely separate API call?
For instance:
?method=createimage&chart1=https://chart.googleapis.com/chart?chs=250x100&chd=t:60,40&cht=p3&chl=Hello|World
In the example above, I’d like to think of it as (2) query string keys: method and chart1. Is it possible for me to parse the above example as 2 query string keys, leaving the Google Charts API call intact, rather than breaking it down? Could I enclose the call as JSON or something along those lines?
Thanks much! Cheers
Here’s the proper way (using the ParseQueryString method):
and if you wanted to construct this query string:
Oh and by the way, what you have shown in your question is an invalid query string which is confirmed by the output of the second code snippet I have shown. You should URL encode your
chart1parameter. It’s absolutely against all standards to have more than one?character in a query string.Here’s how the correct query string would look like: