Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix R code for special character query parameters #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abansal21
Copy link

Resolves #379

@CLAassistant
Copy link

CLAassistant commented Jul 14, 2025

CLA assistant check
All committers have signed the CLA.

@abansal21
Copy link
Author

After reviewing this I suggest that we go with removing queryString altogether and just use url,

for an example, take GET request to "https://postman-echo.com/get?codes[web]=1&codes=2&test[]=2&codes=1"

it generates

library(httr)

url <- "https://postman-echo.com/get"

queryString <- list(
  `codes[web]` = "1",
  `codes` = "2,1",
  `test[]` = "2"
)

response <- VERB("GET", url, query = queryString, content_type(""))

content(response, "text")

which gives a response

{
  "args":{
    "codes":{
      "web":"1",
      "2,1":true
    },
    "test":["2"]
  }
. . .
}

But the actual response should be

"args": {
    "codes": {
      "0": "2",
      "1": "1",
      "web": "1"
    },
    "test": [
      "2"
    ]
  }
...

you can see this just by opening the above link

So the correct code generated should be

library(httr)

url <- "https://postman-echo.com/get?codes[web]=1&codes=2&test[]=2&codes=1"

response <- VERB("GET", url, content_type(""))

content(response, "text")

I have this change and can make it in the same pr if the maintainers believe that its appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: R Code Generation Does Not Quote Parameters with Special Characters (e.g., codes[])
3 participants