Search code examples
github-api

How can we search issues on github Rest API with parameters containing whitespace


I am trying to use the github api to search for pull requests that have a specific label. Went through the documentation https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28

And built the following curl command:

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer XXXXX" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/myorg/myrepo/issues?labels=My%20PR%20Label

But the command returns "no matches found"

When I look for the label itself, I can find it

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer XXXXX" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/myorg/myrepo/issues/2710/labels

[
  {
    "id": XXX,
    "node_id": "XXXX",
    "url": "https://api.github.com/repos/dktunited/myorg/labels/My%20PR%20Label",
    "name": "My PR Label",
    "color": "8DFA3A",
    "default": false,
    "description": "A custom PR label"
  }
]

I have tried the gemini interface they have on their support page, which says my url is correctly formatted.

Can anyone please point out what am I doing wrong ? I have created a support ticket but noone answered yet.


Solution

  • The github support answered. it seems we have to use another syntax for the whitespace included parameters to work

    curl -L \
      -H "Accept: application/vnd.github+json" \
      -H "Authorization: Bearer XXXX" \
      -H "X-GitHub-Api-Version: 2022-11-28" \
      "https://api.github.com/repos/myorg/myrepo/issues?label:\"My%20PR%20Label\""