Curl command not working for Zapier REST hook - rest

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.

Related

SendGrid: "batch id not found"

I'm playing around with the v3 API and trying to demo the concept of scheduling emails and then cancelling them. Here is what I did:
Created a batch with POST https://api.sendgrid.com/v3/mail/batch and got batch a batch ID
Did a mail send with POST https://api.sendgrid.com/v3/mail/send and included that batch ID as the batch_id parameter and put in a future send_at time
Attempted to pass that batch ID into POST https://api.sendgrid.com/v3/user/scheduled_sends/:batch_id
However the latter call fails as 404 Not Found with "message": "batch id not found". In fact it would seem that however many batch IDs I create, attempting to update them always yields this not-found message. The result is, the scheduled send cannot be cancelled, and the email sends at the appointed time. I should add that attempting to GET /v3/mail/batch/{batch_id} returns an empty array [].
Am I doing something wrong here?? Is this a limitation of the free account perhaps?
EDIT: I'm going to add some raw details to show what I am doing. I am doing these in Postman but I will export in cURL syntax to demonstrate.
First I create a batch:
curl --location --request POST 'https://api.sendgrid.com/v3/mail/batch' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token redacted>' \
--data-raw ''
Response: {"batch_id":"OWU0NzgxYzUtMjkzZS0xMWVkLTg5NDAtYWUyMDAwNjVjZGU0LTZiODk2MDliZA"}
So now the next thing I want to try is to verify that batch ID:
curl --location --request GET 'https://api.sendgrid.com/v3/user/scheduled_sends/OWU0NzgxYzUtMjkzZS0xMWVkLTg5NDAtYWUyMDAwNjVjZGU0LTZiODk2MDliZA' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token redacted>'
The response is, oddly, a 200 OK with just [] which doesn't seem right does it? I created a batch and it has an ID, so why can't I verify its existence?
Documentation here states: https://docs.sendgrid.com/api-reference/cancel-scheduled-sends/validate-batch-id
When you pass a valid batch_id to this endpoint, it will return a 200
status code and the batch ID itself.
If you pass an invalid batch_id to the endpoint, you will receive a
400 level status code and an error message.
A batch_id does not need to be assigned to a scheduled send to be
considered valid. A successful response means only that the batch_id
has been created, but it does not indicate that it has been associated
with a send.
Interestingly if I put any arbitrary string in that URL instead of a batch ID, I also get a 200 OK with empty array. I cannot even reproduce what the document is saying about receiving a 400 error for an invalid ID.
However if I take it on faith that the batch WAS created, I would go ahead and try to send an email with it:
curl --location --request POST 'https://api.sendgrid.com/v3/mail/send' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token redacted>' \
--data-raw '{
"batch_id": "OWU0NzgxYzUtMjkzZS0xMWVkLTg5NDAtYWUyMDAwNjVjZGU0LTZiODk2MDliZA",
"send_at": 1661969713,
"personalizations": [{
"to": [{
"email": "thatemail#mycompany.com",
"name": "John Doe"
}
]
}],
"from": {
"email": "myemail#mycompany.com",
"name": "Jane Doe"
},
"reply_to": {
"email": "customer_service#example.com",
"name": "Example Customer Service Team"
},
"subject": "Example Email 6",
"content": [{
"type": "text/html",
"value": "<p>Test email!</p><p>%open-track%</p>"
}
],
"custom_args":{
"sf-id": "some-arbitrary-id6",
"sf-org-id": "some-arbitrary-org-id"
},
"mail_settings": {
"sandbox_mode": {
"enable": false
}
},
"tracking_settings": {
"click_tracking": {
"enable": true,
"enable_text": false
},
"open_tracking": {
"enable": true,
"substitution_tag": "%open-track%"
},
"subscription_tracking": {
"enable": false
}
}
}
'
At the time of writing that timestamp is for 3h from now, resolving at 2:15PM August 31st Eastern Time. I send that call and get 202 Accepted.
Then, finally, I attempt to pause the batch.
curl --location --request PATCH 'https://api.sendgrid.com/v3/user/scheduled_sends/OWU0NzgxYzUtMjkzZS0xMWVkLTg5NDAtYWUyMDAwNjVjZGU0LTZiODk2MDliZA' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token redacted>' \
--data-raw '{"status": "pause"}'
My response is a 404 NOT FOUND with:
{
"errors": [
{
"field": null,
"message": "batch id not found"
}
]
}
So... what is going on here???
So a few things:
It turns out I was missing a step here. The first time I want to put in a pause or cancel on a batch, I actually need to POST /v3/user/scheduled_sends/ with batch_id in the request body. I was trying PATCH. Strange behaviour here as the batch ID already exists, but OK.
After my first successful test of this, the entire behaviour of the GET /v3/mail/batch/{batch_id} API changed for me. I am no longer able to reproduce getting back an empty array. Every response is either a success with the batch ID or a fail.
I don't know why these behaviours changed, but they did. There may be some quirk in which fresh accounts that have never paused/cancelled a batch simply do not have a functional "validate batch" call. Now that I have done a successful pause for the first time, the behaviour of GET /v3/mail/batch/{batch_id} finally matches the documentation.

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.

Facebook Messenger bot welcome message: 100 The parameter setting_type is required

I'm trying to set a welcome message for a Facebook Messenger bot using the code provided in the documentation - with my own page ID and page access token
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[{
"message":{
"text":"Hello! This is a Messenger bot!"
}
}]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
This returns the following:
{"error":{"message":"(#100) The parameter setting_type is required","type":"OAuthException","code":100,"fbtrace_id":"B0DKyn9O2KB"}}
Any ideas on how to solve this? Thanks.
I had the same problem! Some strange copy/paste error with the cURL command from fb...
It didn't work with cURL, but then I used "Advanced REST client" (Chrome plugin) and I was able to set the Welcome Message.
I've tried those exact params with my own page and they worked fine.
Can you try these steps?
Get your page ID and a fresh access token from the Facebook developer console
Make the request from https://developers.facebook.com/tools/explorer to make sure it isn't a problem with cURL
I was having the same issue and the reason was just stupid:
I made copy paste from FB doc and some quotes were wrong. They were ” instead of ".
Open your file in vi or something and search for all quotes so that u can easily understand which are wrong.
I had the same issue, i solved it be calling the URL by postman.check image
There seems to be a problem with windows cmd interpreting the commands. Can you try the same code using Cygwin. It worked well for me. Cheers
this is what works for me
curl --location --request POST 'https://graph.facebook.com/v13.0/your_api_id/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your_App_Token' \
--data-raw '{
"messaging_product": "whatsapp",
"preview_url": false,
"recipient_type": "individual",
"to": "33732473829",
"type": "text",
"text": {
"body": "Hello,"
}
}'
I had to specify the access token in the header

Https Error in Postman when Send push notification via Rest

I'm fairly new To Parse with Rest Api
I wanna test samples in Their Webistes's ( Here ) in Postman But every time I Post it gives me following Authentication error :
I Wanna test following code in Postman ( see origin here )
curl -X POST \
-H "X-Parse-Application-Id: 0VoIZO8cgmnyfiuklLLkKkxOX7r" \
-H "X-Parse-REST-API-Key: UjU5eb5zjic75mPZVdHExYqnneT" \
-H "Content-Type: application/json" \
-d '{
"deviceType": "ios",
"deviceToken": "0123456789abcdef0123456789cdef0123456789abcdef",
"channels": [
""
]
}' \
https://api.parse.com/1/installations
How Can I resolve this issue ? What is that ? And What is required ?
You are reqeuesting GET request and api doc says its POST request.
1) Enter correct url and select POST request method. Add required headers as per the doc.
2) Enter raw JSON data in your request body.
3) You will receive your output. Since api key and application id is not valid so that I received unauthorized error.

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.