Search code examples
socratasoda

What am I doing wrong to get an 500 statusCode


Is this code supported by soda-js, and if so, why am I getting a 500 status code

var identifier = 'fgzt-sd3n'
var op = new soda.Consumer('data.cms.gov', options);
op.query()
    .withDataset(identifier)
    .where({npi:"in('1598908824','1194758300')"})
    .getRows()
    .on('success', function(rows){console.log(rows)})
    .on('error', function(error){console.log(error)})
}

Also can my list be an array or atleast a string variable maybe like

'in('+strList+')'

where

var strList="'1598908824','1194758300'"

Solution

  • Try this instead:

    var identifier = 'fgzt-sd3n' var op = new
    soda.Consumer('data.cms.gov', options); op.query()
        .withDataset(identifier)
        .where({"npi in('1598908824','1194758300')"})
        .getRows()
        .on('success', function(rows){console.log(rows)})
        .on('error', function(error){console.log(error)}) }
    

    I suspect that the where you were passing before got you a SoQL query of $where=npi=in(...) which would fail.

    You should have received a 400 error instead of an unhelpful 500 - I'll file a bug on that one!