Skip to content
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

Failing to fetch when endpoint doesn't end in .json #1594

Closed
ulm0 opened this issue Mar 23, 2018 · 2 comments
Closed

Failing to fetch when endpoint doesn't end in .json #1594

ulm0 opened this issue Mar 23, 2018 · 2 comments
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge

Comments

@ulm0
Copy link

ulm0 commented Mar 23, 2018

Trying to create a custom dynamic badge fails 'cause it doesn't contain .json extension although is json-fomatted

https://img.shields.io/badge/dynamic/json.svg?label=stars&uri=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2Fulm0%252Fgitlab-runner&query=%24.star_count&colorB=blue results in the following badge:

badge

Used curl with the uri and it returns a json file

$ curl https://gitlab.com/api/v4/projects/ulm0%2Fgitlab-runner
{"id":2923852,"description":"GitLab Runner (**Docker image**) for ARM devices","name":"GitLab Runner ARM","name_with_namespace":"Pierre Ugaz / GitLab Runner ARM","path":"gitlab-runner","path_with_namespace":"ulm0/gitlab-runner","created_at":"2017-03-18T11:50:35.869Z","default_branch":"master","tag_list":["arm","ci","continuous integration","docker","gitlab","runner"],"ssh_url_to_repo":"[email protected]:ulm0/gitlab-runner.git","http_url_to_repo":"https://gitlab.com/ulm0/gitlab-runner.git","web_url":"https://gitlab.com/ulm0/gitlab-runner","avatar_url":"https://assets.gitlab-static.net/uploads/-/system/project/avatar/2923852/runner_logo_arm.png","star_count":11,"forks_count":4,"last_activity_at":"2018-03-22T15:45:03.674Z"}%

Getting a pretty output

$ curl https://gitlab.com/api/v4/projects/ulm0%2Fgitlab-runner |\
jq '.'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   727  100   727    0     0    707      0  0:00:01  0:00:01 --:--:--   707
{
  "id": 2923852,
  "description": "GitLab Runner (**Docker image**) for ARM devices",
  "name": "GitLab Runner ARM",
  "name_with_namespace": "Pierre Ugaz / GitLab Runner ARM",
  "path": "gitlab-runner",
  "path_with_namespace": "ulm0/gitlab-runner",
  "created_at": "2017-03-18T11:50:35.869Z",
  "default_branch": "master",
  "tag_list": [
    "arm",
    "ci",
    "continuous integration",
    "docker",
    "gitlab",
    "runner"
  ],
  "ssh_url_to_repo": "[email protected]:ulm0/gitlab-runner.git",
  "http_url_to_repo": "https://gitlab.com/ulm0/gitlab-runner.git",
  "web_url": "https://gitlab.com/ulm0/gitlab-runner",
  "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/project/avatar/2923852/runner_logo_arm.png",
  "star_count": 11,
  "forks_count": 4,
  "last_activity_at": "2018-03-22T15:45:03.674Z"
}
@RedSparr0w
Copy link
Member

Just a quick note for anyone looking into the issue:
It is not failing because the endpoint doesn't end with a .json extension,
It is because the url is returning a 404 status code:
https://gitlab.com/api/v4/projects/ulm0%2Fgitlab-runner ends up being changed to https://gitlab.com/api/v4/projects/ulm0/gitlab-runner.

The change happens on this line.

@paulmelnikow paulmelnikow added bug Bugs in badges and the frontend service-badge New or updated service badge labels Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge
Projects
None yet
Development

No branches or pull requests

3 participants