Authorization Error: username: 'value must be a non-blank string.'

I've tried all sorts of method to try and make this work. Stringifying everything, certain areas, using completely different post methods, using different ways of forming data (hashMap, FormData). This error persists and I have no clue on how or why. The only thing I have of note that I think is causing this is this is not a local host nor my metabase. Its a communities I'm currently just trying to gather data from. But I honestly don't think this error would be a default for not having access to the metabase.

Code(NodeJS) :

var userInfo = {
    'username': 'email',
    'password': 'password'
};

var options = {
    url: 'https://url/api/session/',
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    body: userInfo
};

var response = await axios.post('https://url/api/session/', options)
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error.response);
});

Hi @NotEverEnough
It's data, not body. Try something like this instead:

var userInfo = {
    'username': 'email',
    'password': 'password'
};

var options = {
    url: 'https://url/api/session',
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    data: userInfo
};

var response = await axios(options)
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error.response);
});

And you can probably do something like this to simplify even more:

var userInfo = {
    'username': 'email',
    'password': 'password'
};

var response = await axios.post('https://url/api/session', userInfo)
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error.response);
});

The best way to learn the API, is to just use Metabase while having your browser developer Network-tab open and looking at the request, and what data is being send/received.
For reference: https://www.metabase.com/docs/latest/api-documentation.html

I've tried so many things similar to the second variation its embarrassing I didn't do that. The second variation you sent works just perfectly. Thank you for the quick and perfect response!