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:
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"
}
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.
Most helpful comment
Just a quick note for anyone looking into the issue:
It is not failing because the endpoint doesn't end with a
.jsonextension,It is because the url is returning a
404status code:https://gitlab.com/api/v4/projects/ulm0%2Fgitlab-runnerends up being changed tohttps://gitlab.com/api/v4/projects/ulm0/gitlab-runner.The change happens on this line.