aacerox/node-rest-client

data attribute returned is a buffer

Opened this issue · 1 comments

data is:
<Buffer 3c 68 74 6d 6c 3e 0d 0a 3c 68 65 61 64 3e 3c 74 69 74 6c 65 3e 34 31 34 20 52 65 71 75 65 73 74 2d 55 52 49 20 54 6f 6f 20 4c 61 72 67 65 3c 2f 74 69 ... >

after post:

data.toString('utf8') gives:

<html>
<head><title>414 Request-URI Too Large</title></head>
<body bgcolor="white">
<center><h1>414 Request-URI Too Large</h1></center>
<hr><center>nginx</center>
</body>
</html>

Which is an entire other issue...

I've had this issue when failing to pass appropriate headers to the API in question. Setting my HTTP headers to Accept application/json and a suitable User-Agent string produced the parsed JSON response I was looking for.

Example code would be useful in diagnosing your issue.