Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js HTTPS POST Request Headers

Node.js HTTPS POST Request Headers


I want to post a status update to a Facebook Group using Node.js. It seems Node.js doesn't send the header…

var https = require('https');

var options = {
    host: '',
    port: 443,
    path: '/'+group_id+'/feed?access_token='+access_token,
    method: 'POST',
    headers: { 'message': text }

var req = https.request(options, function(res) {
    console.log("statusCode: ", res.statusCode);
    console.log("headers: ", res.headers);

    res.on('data', function(d) {


This is the log data:

statusCode:  400
headers:  { 'cache-control': 'no-store',
  'content-type': 'text/javascript; charset=UTF-8',
  expires: 'Sat, 01 Jan 2000 00:00:00 GMT',
  p3p: 'CP="Facebook does not have a P3P policy. Learn why here:"',
  pragma: 'no-cache',
  'www-authenticate': 'OAuth "Facebook Platform" "invalid_request" "(#100) A post to a group must have at least a message or attachment"',
  'x-fb-rev': '443252',
  'set-cookie': [ 'datr=removed; expires=Tue, 17-Sep-2013 12:18:08 GMT; path=/;; httponly' ],
  'x-fb-server': '',
  connection: 'close',
  date: 'Sun, 18 Sep 2011 12:18:08 GMT',
  'content-length': '115' }
{"error":{"message":"(#100) A post to a group must have at least a message or attachment","type":"OAuthException"}}
Problem courtesy of: Ph99Ph


I think you need to send the Message (the contents of your variable called 'text') in the body of your request, not the head. See this answer for an example of how to do this.

Solution courtesy of: Luke Girvin


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js HTTPS POST Request Headers


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription