I was recently writing a mobile application using Apache Cordova along with Ionic framework. I kept getting a status 406 response when I was trying to post some data to the API. Since the API was not written by me and I had no access to it either I ended up wasting a good hour on it, since every person with a 406 error seems to have had a different solution each time.
So after awhile I finally asked someone with access to the server logs to check the requests made with my data key and send them to me.
I cannot post that here since it’s a private api, however long strory short, the problem was witht the content type header.
Instead of application/json, I had used application/JSON.
I know, I know, simple mistake, but it’s often the simplest of things that get overlooked, specially since 406 is so cryptic….
TL;DR If you keep getting a cryptic 406 error with a Not Acceptable header, check you content type characters and case.