I´m getting this error when I run this code in my job´s computer.
This is the code:
const { GoogleSpreadsheet } = require("google-spreadsheet");
const creds = require('./credentials.json');
const doc = new GoogleSpreadsheet('11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o'); // Please set your Spreadsheet ID.
const accessSheet = async () => {
await doc.useServiceAccountAuth(creds);
await doc.loadInfo();
const worksheet = doc.sheetsByIndex[0];
const rows = await worksheet.getRows();
rows.forEach((row) => {
console.log(row.Title);
});
};
accessSheet();
This is the error message:
C:Usersrodrigo.pasiniDesktoprobo_grprnode_modulesaxioslibcorecreateError.js:16
var error = new Error(message);
^
Error: Request failed with status code 501
at createError (C:Usersrodrigo.pasiniDesktoprobo_grprnode_modulesaxioslibcorecreateError.js:16:15)
at settle (C:Usersrodrigo.pasiniDesktoprobo_grprnode_modulesaxioslibcoresettle.js:17:12)
at IncomingMessage.handleStreamEnd (C:Usersrodrigo.pasiniDesktoprobo_grprnode_modulesaxioslibadaptershttp.js:269:11)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
config: {
url: '/',
method: 'get',
headers: {
Accept: 'application/json, text/plain, */*',
Authorization: 'Bearer ya29.c.b0AXv0zTNo1VOXxOJkI-s603JwxUfimP6wwbgy21VJGc-a_pqL8g8x1ZBeKn6R8rQELVf7UJrhLxeSRaBDEIvl20IIrmdNzQ4rT-Ke9j2OVwGAeUgqJ3ju49RGU5gTYbX-ljGuWJ9bSjcR5yvUNTBZFRJRFgw939XhGPZnpioCFFDNHDR5I5k-xZGU6-EAPCT8mZufFMLHNFMLPMdx_zeAoj0YtqokAvM........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................',
'User-Agent': 'axios/0.21.4',
host: 'sheets.googleapis.com',
'Proxy-Authorization': 'Basic cm9kcmlnby5wYXNpbmk6Um9kcmlnbzIyMTI='
},
params: {},
baseURL: 'https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o',
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
paramsSerializer: [Function: paramsSerializer],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
data: undefined
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
prefinish: [Function: requestOnPrefinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: <ref *2> Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: 'proxypge01.pge.parana',
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: false,
endEmitted: false,
reading: true,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: true,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_events: [Object: null prototype] {
end: [Function: onReadableStreamEnd],
free: [Function: onFree],
close: [ [Function: onClose], [Function: socketCloseListener] ],
timeout: [Function: onTimeout],
agentRemove: [Function: onRemove],
error: [Function: socketErrorListener],
finish: [Function: bound onceWrapper] { listener: [Function: destroy] }
},
_eventsCount: 7,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: true,
needDrain: false,
ending: true,
ended: true,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 1,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
parser: null,
_httpMessage: [Circular *1],
[Symbol(async_id_symbol)]: 40,
[Symbol(kHandle)]: TCP {
reading: true,
onconnection: null,
[Symbol(owner_symbol)]: [Circular *2]
},
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(RequestTimeout)]: undefined
},
_header: 'GET https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o/ HTTP/1.1rn' +
'Accept: application/json, text/plain, */*rn' +
'Authorization: Bearer ya29.c.b0AXv0zTNo1VOXxOJkI-s603JwxUfimP6wwbgy21VJGc-a_pqL8g8x1ZBeKn6R8rQELVf7UJrhLxeSRaBDEIvl20IIrmdNzQ4rT-Ke9j2OVwGAeUgqJ3ju49RGU5gTYbX-ljGuWJ9bSjcR5yvUNTBZFRJRFgw939XhGPZnpioCFFDNHDR5I5k-xZGU6-EAPCT8mZufFMLHNFMLPMdx_zeAoj0YtqokAvM........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................rn' +
'User-Agent: axios/0.21.4rn' +
'host: sheets.googleapis.comrn' +
'Proxy-Authorization: Basic cm9kcmlnby5wYXNpbmk6Um9kcmlnbzIyMTI=rn' +
'Connection: closern' +
'rn',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype] {
free: [Function (anonymous)],
newListener: [Function: maybeEnableKeylog]
},
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object: null prototype] { path: null },
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {
'proxypge01.pge.parana:8080:': [
<ref *2> Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: 'proxypge01.pge.parana',
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
parser: null,
_httpMessage: [Circular *1],
[Symbol(async_id_symbol)]: 40,
[Symbol(kHandle)]: [TCP],
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(RequestTimeout)]: undefined
}
]
},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: 'https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o/',
_ended: true,
res: IncomingMessage {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: true,
endEmitted: true,
reading: false,
constructed: true,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
destroyed: true,
errored: null,
closed: true,
closeEmitted: true,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: true,
dataEmitted: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_events: [Object: null prototype] {
end: [ [Function: responseOnEnd], [Function: handleStreamEnd] ],
data: [Function: handleStreamData],
error: [Function: handleStreamError]
},
_eventsCount: 3,
_maxListeners: undefined,
socket: <ref *2> Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: 'proxypge01.pge.parana',
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: false,
endEmitted: false,
reading: true,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: true,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_events: [Object: null prototype] {
end: [Function: onReadableStreamEnd],
free: [Function: onFree],
close: [ [Function: onClose], [Function: socketCloseListener] ],
timeout: [Function: onTimeout],
agentRemove: [Function: onRemove],
error: [Function: socketErrorListener],
finish: [Function: bound onceWrapper] {
listener: [Function: destroy]
}
},
_eventsCount: 7,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: true,
needDrain: false,
ending: true,
ended: true,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 1,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
parser: null,
_httpMessage: [Circular *1],
[Symbol(async_id_symbol)]: 40,
[Symbol(kHandle)]: TCP {
reading: true,
onconnection: null,
[Symbol(owner_symbol)]: [Circular *2]
},
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(RequestTimeout)]: undefined
},
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [
'Server',
'squid/3.4.8',
'Mime-Version',
'1.0',
'Date',
'Thu, 05 May 2022 17:03:37 GMT',
'Content-Type',
'text/html',
'Content-Length',
'0',
'X-Squid-Error',
'ERR_UNSUP_REQ 0',
'X-Cache',
'MISS from spge00007',
'X-Cache-Lookup',
'NONE from spge00007:8080',
'Via',
'1.1 spge00007 (squid/3.4.8)',
'Connection',
'close'
],
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 501,
statusMessage: 'Not Implemented',
client: <ref *2> Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: 'proxypge01.pge.parana',
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: false,
endEmitted: false,
reading: true,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: true,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_events: [Object: null prototype] {
end: [Function: onReadableStreamEnd],
free: [Function: onFree],
close: [ [Function: onClose], [Function: socketCloseListener] ],
timeout: [Function: onTimeout],
agentRemove: [Function: onRemove],
error: [Function: socketErrorListener],
finish: [Function: bound onceWrapper] {
listener: [Function: destroy]
}
},
_eventsCount: 7,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: true,
needDrain: false,
ending: true,
ended: true,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 1,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: false,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
parser: null,
_httpMessage: [Circular *1],
[Symbol(async_id_symbol)]: 40,
[Symbol(kHandle)]: TCP {
reading: true,
onconnection: null,
[Symbol(owner_symbol)]: [Circular *2]
},
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(RequestTimeout)]: undefined
},
_consuming: false,
_dumped: false,
req: [Circular *1],
responseUrl: 'http://proxypge01.pge.parana:8080/https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o/',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: {
server: 'squid/3.4.8',
'mime-version': '1.0',
date: 'Thu, 05 May 2022 17:03:37 GMT',
'content-type': 'text/html',
'content-length': '0',
'x-squid-error': 'ERR_UNSUP_REQ 0',
'x-cache': 'MISS from spge00007',
'x-cache-lookup': 'NONE from spge00007:8080',
via: '1.1 spge00007 (squid/3.4.8)',
connection: 'close'
},
[Symbol(kHeadersCount)]: 20,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0,
[Symbol(RequestTimeout)]: undefined
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'proxypge01.pge.parana',
protocol: 'http:',
_redirectable: Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError]
},
_eventsCount: 2,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'http:',
path: 'https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o/',
method: 'GET',
headers: {
Accept: 'application/json, text/plain, */*',
Authorization: 'Bearer ya29.c.b0AXv0zTNo1VOXxOJkI-s603JwxUfimP6wwbgy21VJGc-a_pqL8g8x1ZBeKn6R8rQELVf7UJrhLxeSRaBDEIvl20IIrmdNzQ4rT-Ke9j2OVwGAeUgqJ3ju49RGU5gTYbX-ljGuWJ9bSjcR5yvUNTBZFRJRFgw939XhGPZnpioCFFDNHDR5I5k-xZGU6-EAPCT8mZufFMLHNFMLPMdx_zeAoj0YtqokAvM........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................',
'User-Agent': 'axios/0.21.4',
host: 'sheets.googleapis.com',
'Proxy-Authorization': 'Basic cm9kcmlnby5wYXNpbmk6Um9kcmlnbzIyMTI='
},
agent: undefined,
agents: { http: undefined, https: undefined },
auth: undefined,
hostname: 'proxypge01.pge.parana',
port: '8080',
beforeRedirect: [Function: beforeRedirect],
nativeProtocols: {
'http:': {
_connectionListener: [Function: connectionListener],
METHODS: [Array],
STATUS_CODES: [Object],
Agent: [Function],
ClientRequest: [Function: ClientRequest],
IncomingMessage: [Function: IncomingMessage],
OutgoingMessage: [Function: OutgoingMessage],
Server: [Function: Server],
ServerResponse: [Function: ServerResponse],
createServer: [Function: createServer],
validateHeaderName: [Function: __node_internal_],
validateHeaderValue: [Function: __node_internal_],
get: [Function: get],
request: [Function: request],
maxHeaderSize: [Getter],
globalAgent: [Getter/Setter]
},
'https:': {
Agent: [Function: Agent],
globalAgent: [Agent],
Server: [Function: Server],
createServer: [Function: createServer],
get: [Function: get],
request: [Function: request]
}
},
pathname: 'https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o/'
},
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: 'http://proxypge01.pge.parana:8080/https://sheets.googleapis.com/v4/spreadsheets/11NEx5WMijxjuAmT2cRuBDBzUMtS9d8hSirqi9YtAO-o/',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [ 'Accept', 'application/json, text/plain, */*' ],
authorization: [
'Authorization',
'Bearer ya29.c.b0AXv0zTNo1VOXxOJkI-s603JwxUfimP6wwbgy21VJGc-a_pqL8g8x1ZBeKn6R8rQELVf7UJrhLxeSRaBDEIvl20IIrmdNzQ4rT-Ke9j2OVwGAeUgqJ3ju49RGU5gTYbX-ljGuWJ9bSjcR5yvUNTBZFRJRFgw939XhGPZnpioCFFDNHDR5I5k-xZGU6-EAPCT8mZufFMLHNFMLPMdx_zeAoj0YtqokAvM....................................................
When I run in my private computer, it´s run perfectly.
Why this happen? Someone know what’s happening?



