Action: Mutation response says content type of response is \"text/plain\ while my Twilio function is returning json a setting the right content type. #4342
I am trying to do phone verification using Twilio services, one of the involved services in the process is a Twilio function which is the handler for one of my Hasura Actions (I am running Hasura from master branch) but I am getting this error while executing the mutation:
Here is the Twillio function code:
exports.handler = function(context, event, callback) {
const response = new Twilio.Response();
// -----> HERE IS WHERE I SET THE RIGHT CONTENT TYPE
response.appendHeader('Content-Type', 'application/json');
// CORS support
response.appendHeader('Access-Control-Allow-Origin', '*'); // for testing, restrict to your website in prod!
response.appendHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
response.appendHeader('Access-Control-Allow-Headers', 'Content-Type');
const client = context.getTwilioClient();
const service = context.VERIFY_SERVICE_SID
const channel = (typeof event.channel === 'undefined') ? "sms" : event.channel;
const to = event.phoneNumber;
client.verify.services(service)
.verifications
.create({to: to, channel: channel})
.then(verification => {
verification.success = true;
// -----> HERE verification IS AN OBJECT
response.setBody(verification);
response.setStatusCode(200);
callback(null, response);
})
.catch(error => {
response.setBody({
"success": false,
"message": error
})
response.setStatusCode(400);
callback(null, response);
});
};
This is the result of calling that function from Insomnia:
As you can see in the images the response type is JSON.
My Postres version was 11.7, then I upgraded it to 12.2 but the issue still remains.
Any idea why this could be happening? Error and longs in Heroku do not help me to know why this is failing.
Ok, my fault the issue was that Handler comes populated with a placeholder url and when I pasted the real url some parts of that placehoder remained there.
Hi,
I am trying to do phone verification using Twilio services, one of the involved services in the process is a Twilio function which is the handler for one of my Hasura Actions (I am running Hasura from master branch) but I am getting this error while executing the mutation:
Here is the Twillio function code:
This is the result of calling that function from Insomnia:
As you can see in the images the response type is JSON.
My Postres version was 11.7, then I upgraded it to 12.2 but the issue still remains.
Any idea why this could be happening? Error and longs in Heroku do not help me to know why this is failing.