I am trying to create a release using Github's API.
My request works fine in Postman but no matter what I've tried it always fails with curl, including if I just translate my Postman request into curl using Postman.
This is the body of my Postman POST request:
{
"tag_name": "4.2.0",
"target_commitish": "master",
"name": "4.2.0",
"body": "test"
}
I've included an authorization header of type "Basic", where I input my username and a token I have created for this purpose.
I am executing the request against https://api.github.com/repos/<myUsername>/<myRepo>/releases
.
As I said - it works fine, but when I translate it into curl I get the error "Problems parsing JSON".
The translated curl command is:
curl --location --request POST 'https://api.github.com/repos/<myUsername>/<myRepo>/releases' \
--header 'Authorization: Basic <someHashOrSomething>' \
--header 'Content-Type: application/json' \
--data-raw '{
"tag_name": "4.2.0",
"target_commitish": "master",
"name": "4.2.0",
"body": "test"
}'
which I reformat into curl --location --request POST 'https://api.github.com/repos/<myUsername>/<myRepo>/releases' --header 'Authorization: Basic <someHashOrSomething>' --header 'Content-Type: application/json' --data-raw '{ "tag_name": "4.2.0", "target_commitish": "master", "name": "4.2.0", "body": "test"}'
to be on one line.
I also tried (since only the "tag_name" parameter is required):
curl -i -H 'Authorization: token <myToken>' -d '{"tag_name":"4.2.0"}' https://api.github.com/repos/<myUsername>/<myRepo>/releases
curl -i -H 'Authorization: token <myToken>' -d '{"tag_name":"4.2.0"}' https://api.github.com/repos/<myUsername>/<myRepo>/releases --header Content-Type:application/json
curl -d '{"tag_name":"4.2.0"}' -u <myUsername>:<myToken> https://api.github.com/repos/<myUsername>/<myRepo>/releases --header "Content-Type:application/json"
curl -d "tag_name=4.2.0" -u <myUsername>:<myToken> https://api.github.com/repos/<myUsername>/<myRepo>/releases --header "Content-Type:application/json"
Every curl request fails with the "Problems parsing JSON" error.