Home > database >  github actions curl for github api fails with curl: (3) URL using bad/illegal format or missing URL
github actions curl for github api fails with curl: (3) URL using bad/illegal format or missing URL

Time:10-21

I am trying to get all the tags in a repo using GITHUB API curl method from github actions(runs on ubuntu) and I get below error. I used \ to escape quotes and : still having same issue

      curl \                                
        -H \"Accept\: application/vnd.github json\" \   
        -H \"Authorization\: Bearer TOKEN\" \
        \"https\://api.github.com/repos/OWNER/REPO/tags\"

error:

curl: (3) URL using bad/illegal format or missing URL

CodePudding user response:

It may be related to the syntax you used to make the call.

I just tested the service using this workflow implementation in a POC repository, following the GitHub API documentation:

on:
  push:

jobs:
  job1:
    runs-on: ubuntu-latest
    steps:
      - run: |
          curl \
            -H "Accept: application/vnd.github json" \
            -H "Authorization: Bearer $TOKEN" \
            https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/tags
        env:
          TOKEN: ${{ secrets.ACCESS_TOKEN }}

And it worked as expected with this workflow file, if you want to check the output here.

  • Related