api-examples
api-examples copied to clipboard
Error with status code 400 running NodeSampleApplication
Prøver å kjøre Node eksempelet. Har lagt inn fødselsnummer, clientid og secret fra utviklerportalen slik det står beskrevet i README, men får denne erroren når jeg prøver å gjøre et GET kall mot http://localhost:3001/api/data:
yarn run start
yarn run v1.3.2
$ node ./bin/www
yay got {"access_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjRFRjYwMjJFMUNFODJGQ0NEN0UxRjU2OUIzOEJENUU1OTE0OEI5MzAiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJUdllDTGh6b0w4elg0ZlZwczR2VjVaRkl1VEEifQ.eyJuYmYiOjE1NDE4MTMyMDcsImV4cCI6MTU0MTgxNjgwNywiaXNzIjoiaHR0cHM6Ly9hdXRoLnNiYW5rZW4ubm8vaWRlbnRpdHlzZXJ2ZXIiLCJhdWQiOlsiaHR0cHM6Ly9hdXRoLnNiYW5rZW4ubm8vaWRlbnRpdHlzZXJ2ZXIvcmVzb3VyY2VzIiwiQmFua0FQSSIsIkN1c3RvbWVyc0FQSSJdLCJjbGllbnRfaWQiOiJlYWU4ZTBmMzA1YmY0MWUxYmQxNDkxMjQyMzkxZDI3MSIsImNsaWVudF9tZXJjaGFudF9pZCI6IkFwaUJldGE6ODA1MjQ2IiwiY2xpZW50X3NpZCI6ImIzNjg1ZTQ2MzI4NzQzMThiZGY0OTMzYmMwODEwZTQ2Iiwic2NvcGUiOlsiQmFuay5BY2NvdW50cy5yZWFkX2FjY2VzcyIsIkJhbmsuRUZha3R1cmFzLmZ1bGxfYWNjZXNzIiwiQmFuay5UcmFuc2FjdGlvbnMucmVhZF9hY2Nlc3MiLCJCYW5rLlRyYW5zZmVycy5mdWxsX2FjY2VzcyIsIkN1c3RvbWVycy5DdXN0b21lcnMucmVhZF9hY2Nlc3MiXX0.MnQWc9mcG7wZGQeFD70_pH6wd4wggaRKS0swF2-dXFaWus6A8Q1kaQlMbJSmQ4gl1B8tmqYwim3RiXPRyUUDt_oyIMdew-wWyv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9mcG7wZGQeFD70_pH6wd4wggaRKS0swF2-dXFaWus6A8Q1kaQlMbJSmQ4gl1B8tmqYwim3RiXPRyUUDt_oyIMdew-wWyvq0ttoAE9AONyVS8CpEJL8WMzX9U50EHcZSV9GxTJwflhTM85hYA01J-DaREgd7Cfmg2fEQibQcuQVYedtC0MqEJ67ddc1h7JTDHcKmWVaVQIMZpfoBtcAWLuYR4IktPkG7b77iAOtYVH90zg3R4LDeLfSaAUjIeZfEC36LRHPWKG2bASFMtQbCmUiEBYgporwzNUgJf_r2KvAfVDkq-meN8JDIdmMoEb_K2O2O5WaS9z6wGbXdJg',
expires_in: 3600,
token_type: 'Bearer' }
{ Error: Bad Request
at Request.callback (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\index.js:706:15)
at parser (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\index.js:916:18)
at IncomingMessage.res.on (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\parsers\json.js:19:7)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
status: 400,
response:
Response {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
res:
IncomingMessage {
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
socket: [Object],
connection: [Object],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 400,
statusMessage: 'Bad Request',
client: [Object],
_consuming: true,
_dumped: false,
req: [Object],
text: '{"errorType":1,"isError":true,"errorMessage":"Required parameter \'customerId\' not found.","traceId":"5cda9da3-2fc7-4c47-b464-3cf2a825b4c8"}',
read: [Function] },
request:
Request {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
_agent: false,
_formData: null,
method: 'GET',
url: 'https://api.sbanken.no/bank/api/v1/accounts/',
_header: [Object],
header: [Object],
writable: true,
_redirects: 0,
_maxRedirects: 5,
cookies: '',
qs: {},
_query: [],
qsRaw: [],
_redirectList: [],
_streamRequest: false,
req: [Object],
protocol: 'https:',
host: 'api.sbanken.no',
_endCalled: true,
_callback: [Function],
res: [Object],
response: [Circular],
called: true },
req:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'GET /bank/api/v1/accounts/ HTTP/1.1\r\nHost: api.sbanken.no\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: node-superagent/3.8.3\r\nAuthorization: Bearer [<REDACTED_BY_PIRAVP>] Accept: application/json\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/bank/api/v1/accounts/',
_ended: true,
res: [Object],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]: [Object] },
text: '{"errorType":1,"isError":true,"errorMessage":"Required parameter \'customerId\' not found.","traceId":"5cda9da3-2fc7-4c47-b464-3cf2a825b4c8"}',
body:
{ errorType: 1,
isError: true,
errorMessage: 'Required parameter \'customerId\' not found.',
traceId: '5cda9da3-2fc7-4c47-b464-3cf2a825b4c8' },
files: undefined,
buffered: true,
headers:
{ 'transfer-encoding': 'chunked',
'content-type': 'application/json; charset=utf-8',
'access-control-allow-origin': '*',
'x-rate-limit-limit': '1m',
'x-rate-limit-remaining': '29',
'x-rate-limit-reset': '2018-11-10T01:27:47.3400000Z',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
serv: '1',
date: 'Sat, 10 Nov 2018 01:26:47 GMT',
connection: 'close' },
header:
{ 'transfer-encoding': 'chunked',
'content-type': 'application/json; charset=utf-8',
'access-control-allow-origin': '*',
'x-rate-limit-limit': '1m',
'x-rate-limit-remaining': '29',
'x-rate-limit-reset': '2018-11-10T01:27:47.3400000Z',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
serv: '1',
date: 'Sat, 10 Nov 2018 01:26:47 GMT',
connection: 'close' },
statusCode: 400,
status: 400,
statusType: 4,
info: false,
ok: false,
redirect: false,
clientError: true,
serverError: false,
error:
{ Error: cannot GET /bank/api/v1/accounts/ (400)
at Response.toError (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\response.js:94:15)
at ResponseBase._setStatusProperties (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\response-base.js:123:16)
at new Response (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\response.js:41:8)
at Request._emitResponse (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\index.js:752:20)
at parser (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\index.js:916:38)
at IncomingMessage.res.on (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\parsers\json.js:19:7)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
status: 400,
text: '{"errorType":1,"isError":true,"errorMessage":"Required parameter \'customerId\' not found.","traceId":"5cda9da3-2fc7-4c47-b464-3cf2a825b4c8"}',
method: 'GET',
path: '/bank/api/v1/accounts/' },
created: false,
accepted: false,
noContent: false,
badRequest: true,
unauthorized: false,
notAcceptable: false,
forbidden: false,
notFound: false,
unprocessableEntity: false,
type: 'application/json',
charset: 'utf-8',
links: {},
setEncoding: [Function: bound ],
redirects: [] } }
GET /api/data 200 414.788 ms - 2
Klarer ikke helt se hva jeg gjør feil, setter stor pris på tips som kan peke meg i riktig retning!
Det ser ut som problemet er at den ikke finner customerId. I credentials.js filen heter dette feltet clientId. Prøvde å endre denne til customerId, men still no luck.
Fikk løst for http://localhost:3001/api/data - var feil i pathen i eksempelkoden, men de andre endepunktene (http://localhost:3001/api/account/{accountNumber}) fungerer fortsatt ikke.
Feilen for http://localhost:3001/api/account/<REDACTED>
{ Error: cannot GET /bank/api/v1/accounts/<REDACTED>(503)
at Response.toError (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\response.js:94:15)
at ResponseBase._setStatusProperties (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\response-base.js:123:16)
at new Response (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\response.js:41:8)
at Request._emitResponse (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\index.js:752:20)
at parser (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\index.js:916:38)
at IncomingMessage.res.on (C:\Users\pirar\Downloads\api-examples\NodeSampleApplication\node_modules\superagent\lib\node\parsers\json.js:19:7)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
status: 503,
text: '{"errorType":0,"isError":true,"errorMessage":"Could not complete the request due to an expected or unexpected error.","traceId":"21c1f7b2-1c42-40c9-89d9-d631e0f973f4"}',
method: 'GET',
path: '/bank/api/v1/accounts/<REDACTED>' },
created: false,
accepted: false,
noContent: false,
badRequest: false,
unauthorized: false,
notAcceptable: false,
forbidden: false,
notFound: false,
unprocessableEntity: false,
type: 'application/json',
charset: 'utf-8',
links: {},
setEncoding: [Function: bound ],
redirects: [] } }
@piravp Fikk du fiksa dette noensinne? Jeg får bare 401 uten tekst.
Nei, dessverre. Ingen hell her.. :/
@eldoy Bestemte meg for å ta en ny titt på dette. Fikk til å gjøre kallet, men accountNumber skal være accountId.
@piravp @eldoy @codeape2 Hei! Har samme problemet som du hadde. Hvordan løste du det? Er veldig spent på dette prosjektet og hadde satt stor pris på hjelp!