Error: Parse Error Issue whike Making get request using any library

Viewed 477

I'm Making get request with "Content-type" and "Autorization" headers only, But getting

{ Error: Parse Error
    at TLSSocket.socketOnData (_http_client.js:362:20)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at TLSSocket.Readable.push (_stream_readable.js:134:10)
    at TLSWrap.onread (net.js:551:20) bytesParsed: 152, code: 'HPE_UNEXPECTED_CONTENT_LENGTH' } 

error. I have tried many library and not sending any other headers.

 var args = { 
                headers: {  
                    'Content-Type': 'application/json', 
                    'accept': 'application/json',
                    'authorization' : "bearer " + accessToken
                }
            };
        self._client.get("https://api.sipgate.com/v1/groups", args, function (data, response) {  
            if (response.statusMessage == 'OK'){
                if (data != null && data != undefined){  
                    if (data.items != null && data.items != undefined){
                        if (data.items.length > 0){  
                            deffered.resolve(data.items);
                        } else {
                            deffered.reject("data item length zero.");
                        }
                    } else {
                        deffered.reject("data item undefined.");
                    }
                } else {
                    deffered.reject("data undefined.");
                }
            } else {
                deffered.reject("Response Status not ok.");
            }
        });

With POSTMAN the request is successfully fetching the result.

1 Answers

UPDATE: I alerted the sipgate i/o support about this problem. They released a fix today. I already tested it and the problem is solved.

From my research the problem is that sipgate is using transfer-encoding chunked, but includes a content-length header. You can see the explanation here

Related