Error in Facebook Webhook - json

I'm following the steps given by Facebook's webhook setup found here: https://developers.facebook.com/docs/messenger-platform/getting-started/webhook-setup. No more, no less.
And I'm having a hard time in this step:
When I enter the following line curl -H "Content-Type: application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}' in the command line, I get this error:
What could the issue be?

Just delete the ' from the command like this:
curl -H "Content-Type: application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}

Related

Import Xunit results to Xray/Jira

I am using Jira cloud and trying to import the Xunit json report (result.json) generated by cucumber to Jira with Xray using Jira rest API, I've tried various ways to import the reports from command line but so far no luck.
Ex:
curl -H "Content-Type: application/json" -X POST -u ID:token -F "file=D:\Report.json" "https://raheel.atlassian.net/api/v2/import/execution"
curl -H "Content-Type: application/json" -X POST -u user:token --data #"D:\Report.json" "https://raheel.atlassian.net/rest/api/3/issue/DEM-9"
curl -H "Content-Type: application/json" -X POST -u user:token --data #"D:\Report.json" "https://raheel.atlassian.net/rest/raven/2.0/api/Test Execution/DEM-12"
**Error:**
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: https://raheel.atlassian.net/rest/raven/2.0/api/Test%20Execution/DEM-12</message></status>
token=$(curl -H "Content-Type: application/json" -X POST --data #"{ "client_id": "ID","client_secret": "secret" }" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"') curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"D:\Report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
First of all, it seems that you are using Xray Cloud (i.e. Xray for Jira Cloud).
The proper documentation for Xray Cloud's REST API can be found here.
First, you need to create an API key (pair of client id and client secret) on Xray settings.
Then you need to authenticate in order to obtain a token that you'll need to provide in all following requests.
The following example, shows a way of setting a shell variable with the token value, so it can be used in subsequent requests
token=$(curl -H "Content-Type: application/json" -X POST --data #"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
Then you can invoke the REST API endpoint to submit the Cucumber JSON report.
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"Report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
Please note that in order to import Cucumber related results using a cucumber JSON report, your Scenarios need to be properly tagged. You need to follow one of the flows detailed here.

How create Issues with API/CURL to Bitbucket

I'm trying to create issues in Bitbucket with the Windows CURL command, but it doesn't work, I'm getting this error message:
{"type": "error", "error": {"message": "No import job started"}}
My command CURL:
curl -u username:password -X GET https://api.bitbucket.org/2.0/repositories/name/name2/issues/import -H "Content-Type: application/json" --data #data.jsonson
I'm trying to send the following result in JSON:
{
"title": "title"
}
But it doesn't work.
Does anyone know how I can create issues?
I suppose, you should use a different URL path for posting issues, please see here for post method. It should be like this: https://api.bitbucket.org/2.0/repositories/username/reponame/issues
For posting just an issue with a title you could use this:
curl --ssl-no-revoke -u username#password -X POST -H "Content-Type: application/json" -d "{\"title\" : \"test2\"}" https://api.bitbucket.org/2.0/repositories/username/reponame/issues
To post a content of the issue use content tag:
curl --ssl-no-revoke -u username#password -X POST -H "Content-Type: application/json" -d "{\"title\" : \"test2\",\"content\": {\"raw\": \"just test text\", \"markup\": \"plaintext\"}}" https://api.bitbucket.org/2.0/repositories/username/reponame/issues
For example for me this worked (it's my private repo):
curl --ssl-no-revoke -u myaccountname#mypasswordname -X POST -H "Content-Type: application/json" -d "{\"title\" : \"test2\",\"content\": {\"raw\": \"just test texts\", \"markup\": \"plaintext\"}}" https://api.bitbucket.org/2.0/repositories/dvmochalov/testrepo/issues
--ssl-no-revoke - works only for windows curl and it's just in case if you are running Windows with antivirus software or working with proxy.

CURL command not executing in SSH

I am trying to execute a CURL command to set a greeting message for a bot I am building. Guidance from Facebook here: https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text
Example from Facebook:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"greeting",
"greeting":{
"text":"Timeless apparel for the masses."
}
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
I am trying to run that from a SSH command prompt -- the only change I made was make it into 1 line, so that I can execute it from command line in one go.
curl -X POST -H "Content-Type: application/json" -d '{"setting_type":"greeting", "greeting":{"text":"Hi {{user_first_name}}! I am a bot. Simply say 'Hi' to start.. yes, it's as simple as that!"}}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=EAAFXmrm6M8cBAHF2TwfWMnQfksHnZBtQQIHYWjIFpmTffkG"
But, I get this error message from SSH when trying to execute above 1 liner.
-bash: !"}}': event not found
What am I doing wrong here? Any help is appreciated.
You have a problem with single quotes ', you can replace them with \u0027 :
curl -X POST -H "Content-Type: application/json" -d '{"setting_type":"greeting", "greeting":{"text":"Hi {{user_first_name}}! I am a bot. Simply say \u0027Hi\u0027 to start.. yes, it\u0027s as simple as that!"}}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=EAAFXmrm6M8cBAHF2TwfWMnQfksHnZBtQQIHYWjIFpmTffkG"

Bash json request to api

I am trying to post Json data to an api. All i am getting back is an "Invalid Command" error. I have contacted the api developer about the issue and they insist that the error is not in their api.
Here is the request i am trying to send.
$(curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '"{\"key\":\"MYKEY\", \"secret\":\"MYSECRET\", \"data\":{\"instance\":\"UHC\"}}"' https://api.creeper.host/minecraft/startserver)
Here is what i get back
{"status":"error","message":"Invalid: command not found"}
Does this look correct to everyone?
Instead of trying to quote the string (you have an extra set of quotes as well), pass it via standard input.
curl -v -H "Accept: application/json" -H "Content-type: application/json" \
-X POST -d#- https://api.creeper.host/minecraft/startserver <<EOF
{"key": "MYKEY", "secret": "MYSECRET", "data": {"instance": "UHC"}}
EOF

How to call REST API using CURL & SAML TOKEN Auth

My Url is Like:
https://<ip:port>/TestRESTServices/objects/test-folder
JSON data that I want to pass is:
{
"name":"test-1",
"parent-uuid":"126"
}
test-1 is the folder name which i want to create.
When i invoke this url with the data in Poster plugin in firefox via POST it works fine and folder test-1 is created.
//using Content Type : "application/json"
How can I invoke/call this REST API using cURL ?
Need Help.
This is what i tried:
curl -i -H "Accept: application/json" -X POST -d '{"name":"test-1","parent-uuid":"126"}' https://<ip:port>/TestRESTServices/objects/test-folder
It throws an error that curl: (52) Empty reply from server
Unfortunately I don't have a REST API online to try it, but resources that I found suggest the following approaches:
curl -v -H "Content-Type: application/json" -X POST --data "#issue.json" -u login:password http://redmine/issues.json
where the issues.json is a file containing the JSON request.
Resources I found useful:
1, 2
Hope it helps!
For Authentication : Give the userid/password as admin:password
TOKEN=$(curl -s -k -X POST --basic -u "admin:password" "{host}/TestAuthServices/auth/tokens" | sed -rn 's/\{"Token":"([^"]+)".+/\1/p')
After getting this token call curl as:
curl -s -k -X POST -H "Content-Type: application/json" -H "Authorization: X-SAML ${TOKEN}" -d '{"name":"test","parent-uuid":"126"}' "{host}/TestRESTServices/objects/test-folder"