Discussions
result body is not sent to my webhook server.
over 1 year ago by alexbitrap
Hello!
Result body is not sent to my webhook server. What could be the reason? Are there any IP restrictions?
Request:
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Basic '
},
body: JSON.stringify({
script: {
type: 'text',
provider: {type: 'microsoft', voice_id: 'Jenny'},
ssml: 'false',
input: 'test'
},
config: {fluent: 'false', pad_audio: '0.0'},
webhook: 'https://cucbku.online:444/d-id/result',
source_url: 'https://vokrugsveta.ua/wp-content/uploads/2019/10/skeleton4.jpg'
})
};
fetch('https://api.d-id.com/talks', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Server code:
require('dotenv').config();
const path = require('path');
const express = require('express'),
app = express();
const cors = require('cors');
const https = require('https');
const fs = require('fs');
const DOMAIN = process.env.DOMAIN;
app.set('port', process.env.PORT);
app.use(cors({ origin: "*" }));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname + '/files')));
app.post('/d-id/result', async (req, res) => {
const data = req.body;
console.log(data)
res.send('OK').status(200);
});
const port = app.get('port');
const server = https.createServer({
key: fs.readFileSync(`./cert/${DOMAIN}/privkey.pem`),
cert: fs.readFileSync(`./cert/${DOMAIN}/fullchain.pem`)
}, app);
server.listen(port, () =>
console.log(`Server started on port ${port}`)
);
module.exports = {
app
}