Shields: Failing to fetch when endpoint doesn't end in .json

Created on 23 Mar 2018  路  2Comments  路  Source: badges/shields

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"
}

bug service-badge

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 .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.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bryanveloso picture bryanveloso  路  37Comments

paulmelnikow picture paulmelnikow  路  30Comments

Undistraction picture Undistraction  路  31Comments

adamjstone picture adamjstone  路  36Comments

agemooij picture agemooij  路  27Comments