Issue
I have an existing package registry in GitLab called my_package_registry_2.0.4.0. Now using a curl command i am trying to created a new Release and at the same time adding that package registry as an asset. My tag 1.0.0.0 also exists and it is already created in my repo.
Below is the curl command (with no milestone dates, i am not interested in it):
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: myTokenHere" --data '{ "name": "2.0.0.0", "tag_name": "1.0.0.0", "description": "Release manually created from API", "assets": { "links": [{ "name": "Release_1.2.0.0", "url": "https://my.gitlab.space/api/v4/projects/197/packages/generic/my_package_registry_2.0.4.0/1.0.0.0/myZipFile.zip", "link_type":"package" }] } }' --request POST "https://my.gitlab.space/api/v4/projects/197/releases"
When I execute it, it is failing. Below the error:
curl: (6) Could not resolve host: application
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched brace in URL position 1:
{
^
What am i doing wrong?
ATTEMPT #2: If I use double quotes instead of single quotes, i mean, replace:
'Content-Type : application/json'
by
"Content-Type : application/json"
Then I get below error:
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched brace in URL position 1:
{
^
Solution
Finally I resolved it, executing it from cmd.exe needs to put all things within double quotes and escape double quotes within other double quotes, like this:
curl --header "Content-Type: application/json" --header "PRIVATE-TOKEN: myTokenHere" --data "{ \"name\": \"2.0.0.0\", \"tag_name\": \"1.0.0.0\", \"description\": \"Release manually created from API\", \"assets\": { \"links\": [{ \"name\": \"Release_1.2.0.0\", \"url\": \"https://my.gitlab.space/api/v4/projects/197/packages/generic/my_package_registry_2.0.4.0/1.0.0.0/myZipFile.zip\", \"link_type\":\"package\" }] } }" --request POST "https://my.gitlab.space/api/v4/projects/197/releases"
Answered By - Willy Answer Checked By - Gilberto Lyons (WPSolving Admin)