POST to a webhook? - http

I created a Discord webhook for my channel, now I am trying to send a POST request to it so my program automatically saves stuff to the channel. However when I send a post request it doesn't work. I added some screenshots for clarification

Bad Request means that your Request is invalid.
Discord only accepts JSON Request Bodies(See https://discordapp.com/developers/docs/resources/webhook#execute-webhook)
As the docs describe, the body should look like that(it is minimalized, see the documentation, replace message with your message):
{
"content": "message"
}
You can also send a file or an embed using this method.
You can also overwrite the default username/avatar of the webhook if you want to.

Related

Twilio API does not work with JSON but with MultiPartForms

im sending a POST request to this URL: https://verify.twilio.com/v2/Services/[REDACTED]/Verifications
and with that POST request I'm setting the required parameters in a JSON Object as the body.
My issue is that when I send the request with all the correct required parameters like this
{
"To": "[REDACTED VALID PHONE NUMBER]",
"Channel": "sms"
}
I get the following error.
{
"code": 20001,
"message": "Missing required parameter To in the post body",
"more_info": "https://www.twilio.com/docs/errors/20001",
"status": 400
}
If I try using Insomnia and setting the body to MultiPartForm and type in all my required parameters just like before it works. The issue is I cant use multipart forms and I need to use JSON, anyone have an idea why the API is acting like this?
Here is the API docs:
https://www.twilio.com/docs/verify/api/verification
After further testing, YAML and XML don't work either.
This answer isn't very satisfying, but this is how the API works. It would be best if you used content-type=application/x-www-form-urlencoded as it is also done in the documented samples.
It would be nice if it were explicitly mentioned somewhere like it was in the past.
Here's a suggestion then, build yourself a Node.js Twilio Function that takes in a webhook from Twilio, translates the content from application/x-www-form-urlencoded to application/json, and sends it on to your application

PPST request is working as GET Request in Globiflow

I am trying to send the message from Globiflow through REST POST API but it works as GET request. It gets all SMS history from my account as the response.
Please guide me how can I use that API as POST.
Try replacing the "+" with "%2B"

Telegram: Bad Request: failed to get HTTP URL content: two similar links: one works, one doesn't

I'm trying to send two gifs to Telegram:
First:
https://preview.redd.it/1dsyzqgv3os21.gif?s=c4c426909c653ae159c6bd36a79542245b8dd124
Request link:
https://api.telegram.org/botXXX...XXX/sendAnimation?chat_id=#XXXX&animation=https%3A%2F%2Fpreview.redd.it%2F1dsyzqgv3os21.gif%3Fs%3Dc4c426909c653ae159c6bd36a79542245b8dd124
Second:
https://external-preview.redd.it/LD9iy2VqTJPrkBtOCKE9jBdJA3003epxng2LwOIzBzk.gif?s=75a8452ac1000ef27b7cf95b6535163b8cd671ec
Request link:
https://api.telegram.org/botXXX...XXX/sendAnimation?chat_id=#XXXX&animation=https%3A%2F%2Fexternal-preview.redd.it%2FLD9iy2VqTJPrkBtOCKE9jBdJA3003epxng2LwOIzBzk.gif%3Fs%3D75a8452ac1000ef27b7cf95b6535163b8cd671ec
Despite them being rather similar in their structure, only the first one works.
When I try to send the second request I get:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: failed to get HTTP URL content"
}
Why is that? What can I do to fix it?
This is a problem with Telegram's CDN I believe.
I had made a bot to fetch content from Instagram and upload it on Telegram.
This had happened a lot back then so I implemented a mechanism to fetch the photo using my own server and then send the photo by uploading it rather than passing the direct link to Telegram.
Hope this helps others as well.

Smartsheet Callback

I have integrated Smartsheet api in PHP, i am able to create the webhook and enable it. When a change is made in the sheet it hits the callback url. I am not receiving any data related to the change. I have logged the data as $_POST which is empty.
function smartWebhook_post(){
log_message('error','SS data: '.print_r($_POST,true), '', 'smartsf');
$this->response(array('HTTP status'=>200));
}
According to the documentation HTTP status 200 has to be sent back.
Every webhook callback will have a JSON body. So I'd look more closely at how you are handing the POST payload.
Note that the very first callback will be a verification request as per http://smartsheet-platform.github.io/api-docs/?javascript#webhook-verification

JMeter http request DELETE with body

I have proprietary http based API to test from JMeter. Unfortunately some of the endpoints of the API are expecting http DELETE method with a request body (I know its questionable API design to use DELETE with request body, but I have no ability to change that API and need to test it).
How can I test it from JMeter? It seems that standard HttpRequest sampler silently ignores my body payload without any warnings. (When I try it in POSTMAN its sending a request body for DELETE method)
I did find an old JMeter plugin called HTTP Raw Request that somewhat helps but still doesn't auto-calculate "Content-Length:" http header for my body payload...so I have to do it manually for every test case - which is a pain for dynamically generated data payloads.
So my question still remains: How can I test HTTP DELETE with request body from JMeter?
Here is the screenshot:
NOTE1: Starting from jMeter ver. 3.1 (see bugzilla #60358) it was fixed for Http GET request to be able to send body in the request...but DELETE was not added.
NOTE2: See bugzilla #61443 for the DELETE request with body.
NOTE3: I'm using client implementation called "Java".
As per reference docs:
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Request
There are 2 implementations for http request sampler. The non default one called "Java" has this issue with not passing DELETE request body.
Luckily the default implementation called "HttpClient4" that correctly passes request payload for DELETE operation as per JMeter data entry screen.
To change implementations for http request sampler you have to go to "advanced" tab of the HTTP Request Sampler and select client implementation "HttpClient4" instead of "Java". Here is the screenshot:
After that when executed it correctly sends request payload for DELETE operation. Here is the screenshot:

Resources