how to create new comment inside a comment using Box Rest API - box

how to create new comment inside a comment using Box Rest API
there is Field "is_reply_comment"
but don't know how to set value for this field
https://box-content.readme.io/reference#comment-object

To create a new comment in response to an existing comment, you would use the Create Comments API.
The body of the POST would follow the format below, where COMMENT_ID would be the id of the existing/parent comment:
{"item": {"type": "comment", "id": "COMMENT_ID"}, "message": "YOUR_MESSAGE"}
Here is an example using cURL:
curl https://api.box.com/2.0/comments \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"item": {"type": "comment", "id": "COMMENT_ID"}, "message": "YOUR_MESSAGE"}' \
-X POST

Related

Curl command not working for Zapier REST hook

I am making a Zapier App that will contain a basic trigger. I am using REST hook in API configuration. I followed the instructed steps and everything is fine. At the End i get a Webhook URL, when i am creating a Zap.
As per my understanding, i will be using this URL to send POST request. So i use curl terminal command.
curl -X POST -H 'Content-type: application/json' --data '{ message: 'lemon', id: 'abc', season: 'summerTime' }' https://hooks.zapier.com/hooks/catch/7459492/XXXXXX/
I get response
{"id": "8e5bc4fb-a54c-4860-a22f-8896fadc95a1", "request_id": "5eb3c0c0-9a44-4543-81ba-87cd1a0793b0", "attempt": "5eb3c0c0-9a44-4543-81ba-87cd1a0793b0", "status": "success"}
But nothing happens.
This trigger is suppose to print message and season in some slack channel, i.e Zap i created.
Even in task log, no log is generated.
PS: when i do the same POST request with POSTMAN application, it works just
fine. Can anyone tell me what am i doing wrong.
I am new to these stuff.
I believe you're missing quotes around your keys in the data. Try this:
curl -X POST -H 'Content-type: application/json' --data '{ "message": "lemon", "id": "abc", "season": "summerTime" }' https://hooks.zapier.com/hooks/catch/7459492/XXXXXX/
Note that you can "copy as curl" from postman and emulate exactly what it's doing.

Why do i get 400 using AutoML Rest API?

I trained a custom model using Google Cloud AutoML.
Now i am trying to access it, using the script provided by Google.
I tried to vary "content" in any kind of ways.
I also had a look at the information provided here. Surely i did provide the correct path to the key file. Also i checked on the project ID and model ID.
I do have a service account. Billing is enabled too.
export GOOGLE_APPLICATION_CREDENTIALS={key-file-path}
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://automl.googleapis.com/v1beta1/projects/{my-project-ID}/locations/us-central1/models/{my-model-id}:predict \
-d '{
"payload" : {
"textSnippet": {
"content": "happy",
"mime_type": "text/plain"
},
}
}'
I expect the result to be the prediction.
My result looks like this:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Expected a value.\n“happy”,\n \n^",
"status": "INVALID_ARGUMENT"}
Thanks for your comments, John Hanley and Phillipp Möhler!
Actually I can't really tell what happened here.
I followed Johns advice to use a whole sentence. Doing that enabled me to successfully predict something!
Afterwards I was able to use both, single words and sentences.
Deleting the commas seems to have no effect at all.

How to update jenkins credentials via the REST API?

I found this to create credentials in Jenkins using a REST API call, how to update the credentials with a given id using the REST API calls?
curl -X POST 'http://jenkins:8080/credentials/store/system/domain/_/createCredentials' --data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "apicredentials",
"username": "apicredentials",
"password": "P#$$W0rd",
"description": "apicredentials",
"stapler-class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}'
Example with xml file:
$ cat credential.xml
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
<scope>GLOBAL</scope>
<id>apicredentials</id>
<username>manu</username>
<password>bar1</password>
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
$ curl -X POST -H content-type:application/xml -d #credential.xml 'http://USER:KEY#JENKINS_URL:8080/credentials/store/system/domain/_/credential/apicredentials/config.xml'

curl PUT command removes the reviewers from pull-request while trying to edit the description

I am using a curl PUT command to update the pull-request description. It is updating the description but removing the existing (already added) reviewers.
The curl command I am using to update the pull-request description:
curl -s -X PUT -u '<username>':'<password>' -H "Content-Type: application/json" -v -d '{"version": 1, "description": "'"should go together"'"}' https://{bitbucket.com}/rest/api/1.0/projects/{project_key}/repos/{repo_slug}/pull-requests/{pull_request_id}
Unfortunately you need also to pass the reviewers in the curl command:
curl -s --user USER:PASS --data #- --header 'Content-Type:application/json' --request PUT BITBUCKET-SERVER/rest/api/1.0/projects/PROJECT/repos/REPO/pull-requests/PULL-REQUEST <<EOF
{
"version": VERSION,
"description": "DESCRIPTION",
"reviewers": [
{
"user": {
"name": "REVIEWER-1"
},
"user": {
"name": "REVIEWER-2"
}
}
]
}
EOF
The Bitbucket API documentation says:
Note: the reviewers list may be updated using this resource. However
the author and participants list may not.

Create GitHub.com Hook

I am attempting to create a hook using the create hook api found on
http://developer.github.com/v3/repos/hooks/#create-a-hook
but I am getting a 301 when I attempt to post, so I am sure I am doing it wrong...
A couple of questions...
1) How does github know that I can create a hook for that repo if it is private? I am sure I need to authenticate with the POST, but how?
2) Is the following curl statement a valid example of how to create a hook?
curl -v -H "Content-Type: application/json" -X POST -d "{ "name": "cia",
"active": true, "events": [ "push" ], "config": {
"url": "http://requestb.in/######", "content_type": "json" } }"
http://github.com/repos/#####/#####/hooks
I have replaced certain elements with ##### for security sake...
3) If the above is incorrect, may I please have a snippet of a valid example to create a hook for the webhook named "cia"?
curl -usigmavirus24 -v -H "Content-Type: application/json" -X POST -d '{"name": "cia", "active": true, "events": ["push"], "config": {"url": "...", "content_type": "json"}}' https://api.github.com/repos/sigmavirus24/reponame/hooks
Is the correct curl command. The URL you're posting to has to be https://api.github.com/:endpoint where :endpoint in this case is repos/username/reponame/hooks. You also need to use 's around the JSON body for the curl command because otherwise you'll get strings like "{ " concatenated with the output of commands like name, cia, active, events, etc.
Also the -u :username option is necessary for curl so it will tell curl that it MUST authenticate and ask you for the password to do so.
If you don't mind your password being in your bash history (WHICH YOU SHOULD) you can also do -u username:password. Or even better you can base64 encode your credentials in the form username:password and then send that as a header like so: Authentication: Basic <base64-encoded-credentials.