Skip to main content
September 20, 2022
Question

Status code for invalid json in POST API

  • September 20, 2022
  • 2 replies
  • 0 views

Hello,

I have a simple question. The business I am designing for has asked that if an invalid JSON is submitted to the API  the status code returned not be 500.. They have stated that 500 raises all kinds of alarms for them. Is there a way to change this? I have coded errors to be 400 already but that does not affect the JSON being invalid. 

    2 replies

    September 20, 2022

    The response should be 400. 

    September 21, 2022

    You have to check the JSON first if it is valid then send the status code to 200 else 400. To set these value, you have to use httpResponse.