Skip to content Skip to sidebar Skip to footer

Missingproperty Error In Microsoft Bot Framework Request

I am working on an app that uses the Microsoft Bot Framework. My app is written in Node. At this time, I am trying to POST an activity using the following code: var https = require

Solution 1:

You missed Content-Type and Content-Length in your request headers.

Please consider the following code snippet:

var https = require('https');

var token = '[receivedToken]';
var conversationId = '[conversationId]';

var info = JSON.stringify({
  type: 'message',
  text: 'test',
  from: { id: 'user_' + conversationId }
})

var options = {
  host: 'directline.botframework.com',
  port: 443,
  headers: {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json',
    'Content-Length': Buffer.byteLength(info)
  },
  path: '/v3/directline/conversations/' + conversationId + '/activities',
  method: 'POST'                                
};

var request = https.request(options, (res) => {
  console.log(res.statusCode);
  var body = [];
  res.on('data', (d) => {
    body.push(d);
  });

  res.on('end', () => {
    var result = JSON.parse(Buffer.concat(body).toString());
    console.log(result);
  });
});

request.write(info);
request.end();

request.on('error', (err) => {
  console.log(err);
});

Post a Comment for "Missingproperty Error In Microsoft Bot Framework Request"