Hello, I am creating an application for Icinga2 and I am using it’s API to display the data.
However, while trying to reschedule immediate check, I run into this problem:
{
error: Error: Request failed with status code 400
at createError (C:\Projekty\appinga\appinga\backend\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\Projekty\appinga\appinga\backend\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\Projekty\appinga\appinga\backend\node_modules\axios\lib\adapters\http.js:244:11)
at IncomingMessage.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
config: {
url: ‘https://104.248.131.64:5665/v1/actions/reschedule-check’,
method: ‘post’,
data: ‘{“withCredentials”:true,“headers”:{“Authorization”:“Basic cm9vdDo3NTky”,“Accept”:“application/json”,“Content-type”:“application/json”},“body”:{“filter”:"match(\"icinga-server.localdomain*, host.name)&&match(\“swap*, service.name)”,“type”:“Service”,“force”:true}}’,
headers: [Object],
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: ‘XSRF-TOKEN’,
xsrfHeaderName: ‘X-XSRF-TOKEN’,
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus]
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: ‘’,
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header: ‘POST /v1/actions/reschedule-check HTTP/1.1\r\n’ +
‘Accept: application/json, text/plain, /\r\n’ +
‘Content-Type: application/json;charset=utf-8\r\n’ +
‘User-Agent: axios/0.20.0\r\n’ +
‘Content-Length: 262\r\n’ +
‘Host: 104.248.131.64:5665\r\n’ +
‘Connection: close\r\n’ +
‘\r\n’,
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
method: ‘POST’,
insecureHTTPParser: undefined,
path: ‘/v1/actions/reschedule-check’,
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
response: {
status: 400,
statusText: ‘Wrong Accept header’,
headers: [Object],
config: [Object],
request: [ClientRequest],
data: “
Accept header is missing or not set to ‘application/json’.
”},
isAxiosError: true,
toJSON: [Function: toJSON]
}
}
I’m using Axios for communication inside React Native app. Could anyone please describe, what am I doing wrong? Thanks. (Header is absolutely Accept: application/json).