Warm tip: This article is reproduced from stackoverflow.com, please click
curl github node.js

Problems Updating File on GitHub Using Curl From Node JS

发布于 2020-04-08 09:27:46

I am trying to update a file on my GitHub repo using curl. Unfortunately it keeps giving me the same error message of "Problems parsing JSON". The command that I am using is:

curl -i -X PUT -H "Authorization: token <token>" -H "Content-Type: application/json" -d '{\"message\": \"<message>\", \"committer\": { \"name\": \"<name>\", \"email\": \"<email_address>\" }, \"content\": \"<contents_of_file_in_base64>\", \"sha\": \"<SHA_hash>\"}' https://api.github.com/repos/<user>/<repo>/contents/<data_path>

This command is being sent via node js. Anyone have any ideas what I am doing wrong?

Questioner
Scott Kingdon
Viewed
59
Scott Kingdon 2020-02-01 07:47

So I solved it. I had to put 2 double quotes around all the property names and the values. As in {""valueName1"": ""value1"", ""valueName2"": ""value2""}.