Add Device Error: Index 1 out of bounds for length 1 - ArrayIndexOutOfBoundsException when using javascript fetch

Jacob Knaack6 years ago

I am trying to add a device to my deployed Traccar Server and am able to do so via Postman and curl from a bash terminal, But every time I try and send a request from a web client using fetch, I get this:

POST http://54.191.67.180:8082/api/devices 400 (bad request) Index 1 out of bounds for length 1 - ArrayIndexOutOfBoundsException (SecurityRequestFilter:78 < ...)

This is my own deployment of Traccar and I have been able to make successful POSTs to other endpoints but for some reason this one is throws this exception not matter how I form my request.

Any help / suggestions is appreciated.

Anton Tananaev6 years ago

Compare your request with what official web app sends.

Jacob Knaack6 years ago

Thanks Anton, I solved my issue. I was trying to use Basic auth to authenticate my requests to /api/devices, but it looks like when using fetch you must use the credentials: 'include' property when configuring your fetch request.