I want to download attachment file from JIRA with REST API.
I can get json with this kind of url using API token.
https://my-company.atlassian.net/rest/api/latest/issue/MYPROJECT-41
And I found the attachment file url is this.
https://my-company.atlassian.net/secure/attachment/293726/sample-01.csv
But when I get this file with axios, no response back.
If I set timeout seconds, I got this error.
Error: timeout of 10000ms exceeded
at createError (C:\Users\user\dev\bitbucket\my-project\node_modules\axios\lib\core\createError.js:16:15)
at RedirectableRequest.handleRequestTimeout (C:\Users\user\dev\bitbucket\my-project\node_modules\axios\lib\adapters\http.js:303:16)
at RedirectableRequest.emit (node:events:394:28)
at RedirectableRequest.emit (node:domain:470:12)
at Timeout._onTimeout (C:\Users\user\dev\bitbucket\my-project\node_modules\follow-redirects\index.js:166:12)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
config: {
url: 'https://my-company.atlassian.net/secure/attachment/293726/sample-01.csv',
method: 'get',
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.21.4',
host: 'api.media.atlassian.com'
},
auth: {
username: 'user@my-company.co.jp',
password: '********API*TOKEN*******'
},
proxy: { host: '***.MYPROXYIP.***.***', port: '8080', protocol: 'http' },
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 10000,
adapter: [Function: httpAdapter],
responseType: 'text',
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
data: undefined
},
code: 'ECONNABORTED',
request: <ref *1> 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: [Array],
error: [Array],
socket: [Function: destroyOnTimeout]
},
_eventsCount: 3,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'https:',
path: 'https://api.media.atlassian.com/file/************************************/binary?token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv',
method: 'GET',
headers: [Object],
agent: undefined,
agents: [Object],
auth: null,
hostname: '***.MYPROXYIP.***.***',
port: '8080',
beforeRedirect: [Function: beforeRedirect],
nativeProtocols: [Object],
pathname: '/file/************************************/binary',
slashes: true,
hash: null,
search: '?token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv',
query: 'token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv',
href: 'https://api.media.atlassian.com/file/************************************/binary?token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv'
},
_ended: true,
_ending: true,
_redirectCount: 1,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: 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: [TLSSocket],
_header: 'GET https://api.media.atlassian.com/file/************************************/binary?token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'User-Agent: axios/0.21.4\r\n' +
'host: api.media.atlassian.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: 'https://api.media.atlassian.com/file/************************************/binary?token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv',
_ended: false,
res: null,
aborted: true,
timeoutCb: null,
upgradeOrConnect: false,
parser: [HTTPParser],
maxHeadersCount: null,
reusedSocket: false,
host: '***.MYPROXYIP.***.***',
protocol: 'https:',
_redirectable: [Circular *1],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(kError)]: undefined
},
_currentUrl: 'https://***.MYPROXYIP.***.***:8080/file/************************************/binary?token=************************************************************************************************************************************************************************************************************************************************************************************&client=************************************&dl=true&name=sample-01.csv',
_timeout: Timeout {
_idleTimeout: 10000,
_idlePrev: null,
_idleNext: null,
_idleStart: 4530,
_onTimeout: [Function (anonymous)],
_timerArgs: undefined,
_repeat: null,
_destroyed: true,
[Symbol(refed)]: true,
[Symbol(kHasPrimitive)]: false,
[Symbol(asyncId)]: 33,
[Symbol(triggerId)]: 28
},
_isRedirect: true,
[Symbol(kCapture)]: false
},
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
}
I specify proxy protocol ‘http’, but '‘https://.MYPROXYIP..***:8080’ is used, isn’t it?
Is this a bug?
My company proxy is HTTP, so I use.
I’m not familiar with protocol or network.
Please tell me.