var sendData ={
"username":"testadmin3",
"password":"test@admin3"
};
var contents=querystring.stringify(sendData);
var create_options_httpPost = function(){
return{
hostname: leancloudInfo.hostname,
path: path,
port:443,
method:'post',
headers:{
"X-LC-Id": leancloudInfo.appId,
"X-LC-Key": X_LC_Key,
"Content-Type": "application/json"
}
}
};
console.log(create_options_httpPost());
var req=http.request(create_options_httpPost(),function(res){
res.setEncoding('utf-8');
res.on('data',function(data){
console.log('ytfData',data);
return data;
});
});

    req.write(contents);
    req.end();

明明是json,为什么response回复说不是json格式,请求的是/user接口

看起来你的请求正文是 querystring 编码的。

那直接发你们要求的json格式的数据是怎么发的啊

我直接req.write(json),不经过querystring,连response都收不到

用 JSON.stringify 来编码请求正文。

麻烦发一下代码、错误提示、完整请求和响应。