How to post the comments on GitHub pull request page using curl.exe? - github

Are there any possibilities to post the comments on Github pull request page using curl.exe?
I have used the below as below mentioned commands, but it's not working, the comments have not posted on the pull request page. Could you suggest a solution for this?
curl -s -H "UserName:Token" -X POST -d '{"body": "My Review comments"}' "https://api.github.com/repos/UserName/my-docs/issues/11/comments"

In your question you mention "pull request" but your in your curl command you are calling the Issues API....I'll try and limit my answer to what you are attempting to do with the command by making a few changes in the POST headers:
curl -X POST \
-H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/UserName/my-docs/issues/11/comments \
-d '{"body":"My Review comments"}'
If you still run into trouble, run CURL with --verbose or -v option to get more information on what may be happening.

Related

curl command failing to download release asset from private GitHub repo

According to multiple answers provided in other similar questions, I am trying to download a release assed from GitHub using curl, as follows:
curl -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: Bearer XXXXXXXX" -LJO https://github.com/Org/repo/releases/download/0.4.2/repo-linux-amd64
This keep fetching a file with content Not Found.
When opening the link https://github.com/Org/repo/releases/download/0.4.2/repo-linux-amd64 from an authenticated browser window, it does download the file.
I have also tested my token by running
curl -H "Authorization: token XXXXXXXX" https://api.github.com/user
What is more, the token has the right scopes given that
gh release download 0.4.2 --pattern repo-linux-amd64 -R Org/repo
also works (the token value is exported in the GITHUB_TOKEN environment variable).
I have also tried this variation (with token instead of Bearer in the Authorization header) and the end result is the same
curl -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: token XXXXXXXX" -LJO https://github.com/Org/repo/releases/download/0.4.2/repo-linux-amd64
What am I missing?

How to attach docs and import issue at the same time using GitHub API?

I need to import all bug reports and attachments from my internal system to GitHub Issues.
What GitHub API parameter should I use to attach a document in my curl command?
curl -X "POST" \
-H "Accept: application/vnd.github+json" \
-H "Accept: application/vnd.github.VERSION.html" \
-H "Authorization: token <token>" \
https://api.github.com/repos/BT23/demo-repo/issues \
-d '{
"title":"Create an issue in HTML format",
"body":"<H1>Testing HTML tags</H1><P>Does it work?</P>",
"assignee": "BT23",
"milestone": 1,
"labels":["bug", "functional"]
}'
Thanks
I do not see the word file anywhere in Issues API.
And this thread confirms you cannot attach a file during Issue Creation.
Adding a file to issue or pull request seems to be done manually through drag & drop only.

Create Bitbucket Pull Request Comment via REST

I want to create a bitbucket comment after finishing my bamboo build. Unfortunately my rest call didnt work. ALso Im getting no response.
Am I missing something?
curl -u "USER:PASSWORD" -X POST -d '{"body": "Your Message to Comment"}' "http://URL/2.0/repositories/OWNER/REPO/pullrequests/ID/comments"
Execute the following command:
curl -u "USER:PASSWORD" --request POST --data '{"text": "YOUR-COMMENT"}' "BITBUCKET-SERVER/rest/api/1.0/projects/PROJECT/repos/REPO/pullrequests/ID/comments"

how to change/modify title of an issue when you learn more about the issue/underlying issue itself.

I made a generic title while making a github issue. While trying to explain the issue, I discovered some more details underneath which I could add to the title to explain to the developer better.
I tried to change the title but wasn't able to do that, can modify the body of the message but not the title apparently :(
I tried using [github] modify title or modify heading and few other keywords but couldn't find anything in stackoverflow.com
I even re-read https://guides.github.com/features/issues/ just to see if I missed something when I had read it few years ago.
Looking to know.
Update 2021: you can also use the GitHub CLI gh, instead of curl.
2018:
Considering the GitHub API for Issues does include an "edit issue" which does allow for the title to be modified, this should be possible.
Try (using an OAuth token as shown here):
curl -H 'Authorization: Bearer <your OAuth token>' \
-H "Content-Type: application/json-patch+json" \
-H "Accept: application/json" \
-X PATCH \
https://api.github.com/repos/:owner/:repo/issues/:number \
--data '[{ "title": "a new title" }]'
Or:
curl --request PATCH -H "Authorization: token OAUTH-TOKEN" \
https://api.github.com/repos/:owner/:repo/issues/:number \
--data '[{ "title": "a new title" }]'

Bad request when i try to lock file with Box api (curl method)

I try to lock a file via the API BOX but I encounted issue.
I use the code provided the api documenation (https://developers.box.com/docs/ Lock and Unlock section) but the code does not work.
curl https://api.box.com/2.0/files/xxxxxx\
> -H "Authorization: Bearer xxxxxx" \
> -d "lock": null \
> -X PUT
and the return of the API:
{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value 'lock:'. Entity body should be a correctly nested resource attribute name\/value pair"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Bad Request","request_id":"xxxxxxxxx"}curl: (6) Couldn't resolve host 'null'
I did the test by trying to locke a file : same problem.
Several questions:
Is that the lock function has already work? Do you know if box has
changed its code ?
Any help is welcome :)
Nicolas
I had an answer by Suppor team :
There was a typo in the docs. Please try the command again:
Lock:
curl https://api.box.com/2.0/files/FILE_ID
-H "Authorization: Bearer ACCESS_TOKEN"
-d '{"lock": {"type": "lock","expires_at": "2015-12-12T10:55:30-08:00","is_download_prevented": false}}'
-X PUT
Unlock:
curl https://api.box.com/2.0/files/FILE_ID
-H "Authorization: Bearer ACCESS_TOKEN"
-d '{"lock": null}'
-X PUT
https://support.box.com/hc/fr/requests/793456?flash_digest=c5350d2f104f3066b46cb83baa97c23dac863d2b