Spoiler: This is my first time doing any sort of web-interfacing, so might be something obvious.
Problem:
Hard-typing the query into a request works, while using the query=["variables"=>"var1,var2"]
or query=["variables"=>"var1", "variables"=>"var2"]
causes an error on the server side due to URI encoding of the comma.
Example
URL access
Using a dummy URL for demonstartion purposes, but the actual address is public, so if really necessary, I can reveal it.
using HTTP
happyrequest=HTTP.get("https://info.mywebsite.com/my.cgi?variables=var1,var2¶m=10")
sadrequest=HTTP.get("https://info.mywebsite.com/my.cgi", query=["variables"=>"var1,var2", "param"=10)
running the above with verbose=1
#happyrequest
...
...
Debug: HTTP.Messages.Request:
β GET /my.cgi?variables=var1,var2¶m=10 HTTP/1.1
β Accept: */*
β User-Agent: HTTP.jl/1.10.3
β Content-Length: 0
β Accept-Encoding: gzip
...
β HTTP/1.1 200 OK
β Date: Tue, 08 Apr 2025 13:37:41 GMT
β Server: Apache/2.4.58 (Unix) OpenSSL/3.2.1 PHP/8.1.27
β Strict-Transport-Security: max-age=63072000; includeSubDomains
β Transfer-Encoding: chunked
β Content-Type: text/html;charset=iso-8859-1
β
β [
β { "var1": Value1, "var2": Value2 }
β ]
#sadrequest
...
...
Debug: HTTP.Messages.Request:
β GET /my.cgi?variables=var1%2Cvar2¶m=10 HTTP/1.1
β Accept: */*
β User-Agent: HTTP.jl/1.10.3
β Content-Length: 0
β Accept-Encoding: gzip
...
β HTTP/1.1 200 OK
β Date: Tue, 08 Apr 2025 13:21:43 GMT
β Server: Apache/2.4.58 (Unix) OpenSSL/3.2.1 PHP/8.1.27
β Strict-Transport-Security: max-age=63072000; includeSubDomains
β Transfer-Encoding: chunked
β Content-Type: text/html;charset=iso-8859-1
β
β [{ "error": "someLib: RelationalDataBase: SQL Error" }]
The only difference between the requests that I see is the URI-encoding of the comma that separates var1,var2
in the query string. I have attempted to use both ways of assignment of the second variable to the same key:
- Including it into a comma separated string
- Using a dict as per documentation:
HTTP.get(url; query=["x1" => "y1", "x1" => "y2"]
: allows duplicate key values
In both cases a URI-encoding of the comma takes place, causing indigestion on the server side.
Question: is there, maybe, a way to disable the encoding?
I can work around it by doing individual requests for each variable or by manipulating the string of the request. However my gut feeling tells me there should be a better way, right?
Thank you for your time and any (potential) contributions or suggestions.
Igor