WebGet with a Special Character

I've implemented a WebGet method to get a JSON payload from a server. Works perfectly to get data related to cycling.

The server has a convention to append "|running" to the user name to request data associated with running.

Anyway, when I pass "name|running" I get an HTTP 400 error. That often means passing an invalid character in the URL.

I can't figure out how to encode/escape the "|" character if that is the issue...

Using \| doesn't work. Trying to encode the | character like "%20" is used URLs for a space. That would be %7C or &#124. No joy.

  • Anyway, when I pass "name|running" I get an HTTP 400 error.

    I assume the 400 is coming back from Garmin Connect (as a proxy for your device) and not the real server? Or is your device connecting directly to the real server via wi-fi?

    If you're going through Connect then either Connect itself doesn't like "|" in a URL or it's changing the URL somehow so that the server doesn't like it.

    Either way, it seems that either:

    - you could submit a bug report to Garmin, if you can narrow down the issue

    or

    - write a proxy that will access the service for you (so you can talk to your proxy without "|", but the proxy will send "|" as needed)

    Trying to encode the | character like "%20" is used URLs for a space. That would be %7C or &#124. No joy.

    What happens when you do this? Do you still get a 400 or does it fail in a different way?

  • Strangely.... as you likely know, there are two steps to the process. I perform a makeWebRequest where I pass the username and password with a method =>Comm.HTTP_REQUEST_METHOD_POST and that apparently works. I get a STATUS=200 and the access and refresh tokens back. Then I follow up immediately with a method => Comm.HTTP_REQUEST_METHOD_GET and that fails with the -400 error. The ONLY difference between a successful attempt and these "400" failures is the expanded username with the |running part added to the string. Any thoughts? Yes I go thru GCM.

  • Are you trying to pass this as part of the url, or in the params field?  Sounds to me like it's part of the url.  Try moving it to params.

  • Params field. I actually got in touch with the server admin/developer. Now it works. So it was def on the backend, not CIQ or CGM. Thanks!