Twilio API does not work with JSON but with MultiPartForms - http

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

Related

Logic App Http POST request UnsupportedMediaType error

I am getting the following error in my logic app:
{ "type": "https://errors-api.cloud.com/common/unsupportedMediaType", "detail": "Content type '' not supported", "parameters": null }
The following is my set up:
This works in Postman.
However, I noticed that in the Logic App if I add in a text in the Body section. For example "body". It works fine
The Body is not needed in the Postman so it's confusing to me why it needed in Logic app. Anyone come across similar issue?
Issue is with content-type in your case. I have tried to reproduce issue from my side, but I did not get any error. I have found similar issue like you in link
Also, can you add Accept as shown below in header request,
Accept:*/*
I have created logic app as shown below,
In Get Bearer Token, getting access token from authentication url,
Using access token from Get bearer token getting data from api as shown below,
The logic app ran successfully,

How to implement a Google Cloud Platform (GCP) Authorization call via HTTP call in postman

I want to implement an HTTP call to Google Cloud Platform (GCP) to generate the Authorization token.
Cant find a the correct GCP documentation for the same as well.
Using the reference from below URL, I was able to generate a Authorizaton token from Postman, using postmans Authorization UI and not the HTTP call UI.
https://www.vulongtran.com/how-to-use-postman-with-google-cloud-platform-apis
And the call to GCP API are working using the token generated from above process.
I tried implementing the same call via HTTP POST request, but not getting expected result.
HTTP POST
URL - https://accounts.google.com/o/oauth2/token
Query param-
grant_type:authorization_code
redirect_uri:https://www.getpostman.com/oauth2/callback
Authorization -
Basic Auth
username -
password -
Headers -
scope:https://www.googleapis.com/auth/cloud-platform
redirect_uri:https://www.google.com
And the response that I get is
400 bad request
{ "error": "invalid_request", "error_description": "Missing required parameter: code" }
2nd Try-
Also tried sending the in the request BODY, like below, but the result was same.
{
grant_type:'authorization_code',
redirect_uri:'https://www.getpostman.com/oauth2/callback'
}
Response
{
"error": "invalid_request",
"error_description": "Missing required parameter: code"
}
I saw another page, where 'code' is used in the call. Dont know what language the code on that page is for.
But I am unable to figure out the correct HTTP call to get the token from there as well.
Google OAuth2: Required parameter is missing: grant_type

POST to a webhook?

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.

HERE.com Places API, "ApiKey is missing" error message, but it isn't

I've tried the below request (with two different proper API keys), on the HERE Places API, but I get an auth error.
Request:
https://places.sit.ls.hereapi.com/places/v1/autosuggest
?at=40.74917,-73.98529
&q=chrysler
&apiKey=g51V9*****N4-_GTA
Response:
401
{
"error": "Unauthorized",
"error_description": "ApiKey is missing."
}
I've also tried OAuth, I can get the request token, but when I use this for the places request I get an HTML webpage (for HERE place API) as the response, rather than an expected JSON or XML reponse.
Is anyone able to get any of the example requests to work for Places API?
I had this issue before aswell. Trying the exact same request as you, in Postman with my own apiKey, made the request successfull.
Try making the URL a single line, there might be newline characters hidden somewhere.
This has solved this issue for me many times using this API.
Example:
https://places.sit.ls.hereapi.com/places/v1/autosuggest?at=40.74917,-73.98529&q=chrysler&apiKey=g51V9*****N4-_GTA
You need to check the key name it may wrong
you should check it out into the documentation of api. and see key name
try key name apikey or api_key or api-key instead of apiKey
https://places.sit.ls.hereapi.com/places/v1/autosuggest
?at=40.74917,-73.98529
&q=chrysler
&apikey=g51V9*****N4-_GTA
Please refer to this guide for the updated list of domains to use with apiKey.
For places, the domain is: places.ls.hereapi.com
Disclosure: I'm a product manager at HERE Technologies
In my case I was using : https://github.com/julianshen/gin-limiter with the provided example

invalid_grant error when attempting oAuth2 for Box API

I have been attempting to get access tokens for the Box API and am running into a persistent problem. I am following the steps listed on this page. I am able to do the first leg and get a security token from a request to
https://account.box.com/api/oauth2/authorize?response_type=code&client_id=MY_CLIENT_ID&state=security_token%3DKnhMJatFipTAnM0nHlZA
I am then doing a POST request to
https://www.box.com/api/oauth2/token?grant_type=authorization_code&code={CODE_FROM_PREVIOUS_REQUEST}&client_id{MY_CLIENT_ID}&client_secret={MY_CLIENT_SECRET}
I also am including the header
Content-Type: application/x-www-form-urlencoded
With all this I am getting back:
{
"error": "invalid_request",
"error_description": "Invalid grant_type parameter or parameter missing"
}
Is there something I am missing here? Thank you in advance, any help would be appreciated
You're not actually POST-ing the parameters since you've included them in the URL as query parameters. You should pass the parameters as part of the HTTP request body.

Resources