Cannot read properties of undefined for grid.color context

Hi!
We are trying to use only the zero line in the chart grid as can be done by setting all non-zero lines to for example white color, and the zero line to a visible color.

This works fine in an html page using this code:

new Chart("myChart", {type:'bar',data:{labels:['January','February','March','April','May'],datasets:[{label:'Dogs',data:[50,60,-40,-18,19], backgroundColor: '#336699'}]},
  options:{scales:{y:{grid:{color: context => context.tick.value != 0 ? '#FFFFFF' : '#000000'}}}}});

But when trying the same using a POST to the API we receive "Cannot read properties of undefined (reading ‘value’). Sample body of POST:

{
  "backgroundColor": "transparent",
  "width": 300,
  "height": 200,
  "version": "4.4.1",
  "format": "png",
  "chart": "{type:'bar',data:{labels:['January','February','March','April','May'],datasets:[{label:'Dogs',data:[50,60,-40,-18,19], backgroundColor: '#336699'}]},options:{scales:{y:{grid:{color: context => context.tick.value != 0 ? '#FFFFFF' : '#000000'}}}}}"
}

Any hints appreciated!
Torulf