bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Alow Bruno to URL-encode query params, similar to curl's `--url-query`

Open bkane-msft opened this issue 11 months ago • 5 comments

Hello! An API we have to use has query params that need to be URL encoded. We can do this with curl like this:

curl https://endpoint.com/path --url-query "results=a,b,c"

However, when trying Bruno, I realized I had to manually URL encode this myself:

image

Is there a way to be able to add query params that need to be URL encoded in Bruno? Perhaps similar to the "Body" dropdown (see next screenshot for example) that allows Form Encoding: image

bkane-msft avatar Mar 12 '24 16:03 bkane-msft

To add a little more context to this, I tested two other HTTP clients (Hurl - Run and Test HTTP Requests and REST Client - Visual Studio Marketplace) and they each auto-URL-encode query params for me. I'm not sure that's the correct behavior, but it's something I need to ergonomically work with these params. Other than this, Bruno looks awesome, thanks for making it!

Hurl example

GET https://endpoint.com/path
[QueryStringParams]
results: a,b,c

REST Client example

GET https://endpoint.com/path
    ?results=a,b,c

bkane-msft avatar Mar 12 '24 17:03 bkane-msft

+1

It looks like Postman implements this as a "setting" on the Request itself (not global), which is also handy:

image

patclrk avatar Mar 14 '24 12:03 patclrk

+1

Reading a little into the code it seems like axios is being used to send requests and axios should be capable of this feature.


This might be a duplicate of #732

flx-sta avatar Mar 26 '24 15:03 flx-sta

I would love to have this feature. For now, I've put this workaround into my Collection's Pre-Request Script, which splits the request URL into hostname, etc. and parameters, and URI encodes the parameters. So far it hasn't had any issues, but your mileage may vary:

req.setUrl(req.getUrl().replace(/(.+?\?).+/,'$1') + encodeURI(req.getUrl().replace(/.+?\?/,'')))

randoogle avatar Jul 31 '24 20:07 randoogle

Oh, I'm just realizing now that one big issue with my work-around is that the variables aren't getting interpreted before the JavaScript runs (see #2690). I understood this initially, which is why I split the host and parameters apart, but I'm just realizing it makes using variables in the parameters impossible.

randoogle avatar Jul 31 '24 20:07 randoogle