我向服务器发出POST请求并将其取回:
toJSON: [Function: responseToJSON],
caseless:
Caseless {
dict:
{ server: 'Apache-Coyote/1.1',
pragma: 'no-cache',
'cache-control': 'no-store',
'content-encoding': 'gzip',
'content-type': 'application/json;charset=UTF-8',
'content-length': '287',
date: 'Fri, 23 Jun 2017 14:06:47 GMT',
connection: 'close' } },
read: [Function],
body: '\u001f?\b\u0000\u0000\u0000\u0000\u0000\u0000\u0000???j\u0003!\u0014???
?C\u0018??\u0017\u001cG\u001d?k???????L\u0018\r$-}??t?]?v???|???z??4H?9\u000fe:?
??6?X\u0013Zv`?cP\u001c\u0005X?\u0011?\f\u001amKd?m?\u001f?C\u0019????;!-?o?4s\u
001eR???\u0010_t?X????B?\u0018\u001ch?\u001eTo%?3\u0016?tJ?\u000e^j?\u0014f?\u00
1e\u0013??\u0017R?\u0003?+???*{\u0017A???l\u000fd\b??,\u001b\u0015~Hx|??T?SU?\n
?\b?\u0012?k\u0019??+???sA*C\n5??\u0010V?\u001a??c?sY\u001ec$?AH\u000b2?\u0001??
\u0005??\u0015D?\u001db\'HZ??&_cL???$?~W?⌂?>??p????????\u0003z$B??\u0001\u0000\u
0000' }
现在我知道编码"身体中的任何内容"是我正在寻找的,因为当我在Fiddler上做这个帖子请求时,它遵循相同的格式,除了正文是JSON代码。有没有办法解码这个?
编辑:
var options = {
url: someURL,
host: "SomeApi.com",
method: 'POST',
headers: {
'Accept': 'application/json, text/json, text/x-json, text/javascript, text/xml, application/xml',
'User-Agent': 'RestSharp/105.2.3.0',
'Accept-Encoding': 'gzip, deflate',
'Content-Length': '0'
},
}
request(options, function (error, response, body) {
console.log(response)
})