在请求中发送 headers 中的 body 选项

Sending body option in headers in request

我正在尝试使用此 sync-request 库发出 post 请求。而且他们不支持 body 选项,所以我需要在 headers 中手动设置,但我不知道具体如何。

目前我正在尝试这样:

 let req = request('POST', LINK, {
    'headers': {
      'Accept'                    : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
      'Accept-Encoding'           : 'gzip, deflate',
      'Accept-Language'           : 'en-US,en;q=0.8,pt;q=0.6',
      'body'                      : 'ESTCS=1; ESTID=00726861000151',
      'Cache-Control'             : 'max-age=0',
      'Connection'                : 'keep-alive',
      'Content-Length'            : '167',
      'Content-Type'              : 'application/x-www-form-urlencoded',
      'Referer'                   : 
      'Upgrade-Insecure-Requests' : '1',
      'User-Agent'                : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2584.0 Safari/537.36',
      'X-FirePHP-Version'         : '0.0.6'
    }
  });

但是没有任何反应。

我需要在我的 body 中发送两件事:

let body = {
  'ESTCS': 1,
  'ESTID': '00726861000151'
};

我正在尝试这样:

'body': 'ESTCS=1; ESTID=00726861000151',

谢谢。

Body应该是&分开的。试试这样:

'body': 'ESTCS=1&ESTID=00726861000151',