freeSwitch ESL api api originate response -ERR NORMAL_CLEARING - freeswitch

i neel make a call from my application to internal use ESL
use nodejs 'modesl' module
ESL api call response NORMAL_CLEARING WHY ???
api originate {ignore_early_media=true,origination_uuid=e0911776-e4bf-11eb-862f-d3d81f5727e2,originate_timeout=60,hangup_after_bridge=true}sofia/internal/1000#domain &playback(message)
response
headers: [
{ name: 'Content-Type', value: 'api/response' },
{ name: 'Content-Length', value: 21 }
],
hPtr: null,
type: undefined,
subclass: undefined,
body: '-ERR NORMAL_CLEARING\n'
}```

According to the content of API call, the outgoing call will hangup automatically after end of playback.

Related

Files in Google Shared Drive not sending push notifications

I have been able to successfully create and receive webhook events for files in my personal drive, how ever when I try to set them up for a file in a shared drive I receive no events.
I get a status 200 when creating the webhook. So it seems that the webhook for file in the shared drive is being created properly. But after the initial 200 response no events follow no matter which changes to the file are made.
below is the request I have been using.
Perhaps this is a permissions issues but I can't find anything in Google's documentation on how to support push notifications in shared drives.
request({
method: 'POST',
uri:`https://www.googleapis.com/drive/v3/files/{fileId}`,
json: true,
body: {
id: '',
type: 'web_hook',
address: ``,
expiration: expiration_date,
},
headers: { Authorization: `Bearer` },
qs: {
includeItemsFromAllDrives: true,
supportsAllDrives: true,
supportsTeamDrives: true,
},
}),
```
Thanks

malformed lambda proxy response, can't find the error

I'm trying to get data from my api using lambda and API Gateway, when sending the get requests I get this error:
Execution failed due to configuration error: Malformed Lambda proxy response
the code returns:
return {
'statusCode': 200,
'headers': {'Content-Type': 'application/json'},
'Access-Control-Allow-Origin': '*' ,
"isBase64Encoded": False,
'body': json.dumps(data)
}
what am I doing wrong?
The proxy response must be a dictionary which must only contain the following keys:
headers
body
isBase64Encoded
multiValueHeaders
statusCode
In your example you have one additional key Access-Control-Allow-Origin and that's why API Gateway claims that it is a malformed response. The documentation linked above even explicitly states that Access-Control-Allow-Origin must be part of headers:
To enable CORS for the Lambda proxy integration, you must add Access-Control-Allow-Origin:domain-name to the output headers.domain-name can be * for any domain name.
If you change the response to the following it should work fine:
return {
'statusCode': 200,
'headers': {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
},
'isBase64Encoded': False,
'body': json.dumps(data)
}

serverless: When 302 redirect the custom header or set-cookie header not getting passed

I am using aws api gateway with help of serverless.
I am able to redirect to another domain from my lambda function.
like : abc.com ====> API Gateway & Lambda ==[302 redirect]==> xyz.com
I am unable to set custom header or any header.
here is my code.
exports.create = async (event) => {
try {
const token ='uniqueValue';
const response = {
statusCode: 302,
headers: {
Location: 'http://localhost:1337',
bearer_token: token,
'Set-Cookie': token,
'Content-Type': 'application/json'
}
};
return response;
} catch (err) {
console.log(err);
return err;
}
};
my auth-handler.yml looks like this,
auth-token:
handler: modules/auth/endpoints/token.create
memorySize: 128
timeout: 30
events:
- http:
path: /rest/auth/token
method: get
I am unable to set cookie in xyz.com. please help...
Thanks in advance

CORS issues with Serverless Lambda and API Gateway

Solved
The below issue was simply caused by the body property of the response object constructed in my Lambda. I was forgetting to stringify the data, returning body: data instead of body: JSON.stringify(data). This problem with the response appeared to trigger an error with API Gateway which caused the request failures with some rather confusing error messages.
Problem
I'm working on a ecommerce site using React, Serverless and the Stripe API. My front-end React app is making a GET request using Axios to my Lambda function which has been exposed via API Gateway. The Lambda function in turn queries the Stripe API and returns the Stripe response data to my React app. However, I am experiencing CORS issues as my React app tries to call the Lambda, it receives the following error:
Failed to load: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 502.
Querying the Lambda endpoint in Insomnia returns a 502 response with { "message": "internal server error" }. But executing the serverless invoke command from the Lambda function from the terminal successfully returns the Stripe data.
I am enabling cors for the function in my serverless.yml file and including 'Access-Control-Allow-Origin': '*' in my Lambda code response as advised in this Serverless blog post, I have also attempted adding a various combinations of the following headers to my Lambda response and my Axios request based on suggestions found on this issue on Axios and this issue on Serverless. I've deleted and redeployed the service multiple times and
Lambda response headers
headers: {
'Access-Control-Expose-Headers': 'Access-Control-Allow-Origin',
'Access-Control-Allow-Credentials': true,
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
React/Axios config
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
crossDomain: true
}
Currently my code is as follows:
React app
import Axios from 'axios';
import { GET_PRODUCTS_URL } from '../config';
export default () => {
return Axios
.get(GET_PRODUCT_URL, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
crossDomain: true
})
.then(({ data }) => data)
.catch(console.log);
}
Lambda
import Stripe from 'stripe';
const apiKey = process.env.STRIPE_SECRET_KEY;
const stripe = Stripe(apiKey);
module.exports.handler = (event, context, callback) => {
return stripe.products
.list()
.then(({ data }) => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Expose-Headers': 'Access-Control-Allow-Origin',
'Access-Control-Allow-Credentials': true,
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: data,
};
callback(null, response);
})
.catch(console.log);
}
Serverless.yml
service: srd
provider:
name: aws
runtime: nodejs6.10
stage: ${opt:stage, self:custom.defaultStage}
region: eu-west-1
memorySize: 256
timeout: 6
versionFunctions: true
plugins:
- serverless-plugin-optimize
- serverless-plugin-scripts
package:
individually: true
functions:
get-products:
handler: lambda/get-products.handler
name: srd-get-products-${self:provider.stage}
description: 'get srd products from stripe'
environment:
STRIPE_PUBLISHABLE_KEY: ${self:custom.stripe_publishable_key.${self:provider.stage}}
STRIPE_SECRET_KEY: ${self:custom.stripe_secret_key.${self:provider.stage}}
events:
- http:
path: products
method: get
cors: true
custom:
defaultStage: dev
stripe_publishable_key:
dev: ${file(env.yml):STRIPE_DEV_PUBLISHABLE_KEY}
live: ${file(env.yml):STRIPE_LIVE_PUBLISHABLE_KEY}
stripe_secret_key:
dev: ${file(env.yml):STRIPE_DEV_SECRET_KEY}
live: ${file(env.yml):STRIPE_LIVE_SECRET_KEY}
I've been at this for hours, any insights much appreciated.
Edit/Additional
Making an options request from the CLI returns the following:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: keep-alive
Date: Mon, 19 Mar 2018 06:52:12 GMT
x-amzn-RequestId: 0d10c9d1-2b42-11e8-b270-a723e367048e
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent
Access-Control-Allow-Methods: OPTIONS,GET
Access-Control-Allow-Credentials: false
X-Cache: Miss from cloudfront
Via: 1.1 e40b14deb4a844594f746b751f632677.cloudfront.net (CloudFront)
X-Amz-Cf-Id: eMvu3Ke7m7GNFCFgIOGVJmoObFwYMeEt4o8AByoipfMn1nXIi9Vo0g==
The HTTP response code in the CORS error message says 502. This means the server you are requesting is unavailable.
In an event of a 502, the browser cannot make successful OPTIONS requests, so even if your CORS setup in the server is correct, you will still get a CORS error since it was not resolved properly.
Look at your server and make sure it is running as it should. Once the 502 error is fixed, try again and you should be good to go. Try making a manual OPTIONS request, similar to that of what the browser would make, and see if you get the same error.

Send message with Malign via http request

I try to send a message via http request using Mailgun, the system give me back a 200 ok but the message never send.
here my code, (I run my code inside a parse httpReuest function) any idea?
Parse.Cloud.httpRequest({
url: 'https://api:MYAPIKEY#api.mailgun.net/v3/MYDOMAIN.net/message',
params: {
from: 'XX#XX.net',
to: 'XX.XX#gmail.com',
subject: 'Hello',
text: 'Testing some Mailgun awesomness!'
}
}).then(function(httpResponse) {
console.log('Request response ' + httpResponse.error);
}, function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
});
I found the answer... I make a mistake in the api call the right call is.
url: 'https://api:MYAPIKEY#api.mailgun.net/v3/MYDOMAIN.net/messages',
with messages not message
forgot and s and waste the entire day :-(

Resources