title: Test how API handles invalid JSON syntax request body using node.js
body: <p>I would like to test how an REST API handles a POST request that has a body with invalid JSON syntax, for example a missing comma. I'm using node.js to write the API tests. I'm using <a href="https://www.npmjs.com/package/frisby" rel="noreferrer">frisby</a> but I also tried <a href="https://www.npmjs.com/package/supertest" rel="noreferrer">supertest</a>. No luck. With the previous tools, you pass the request body as a JavaScript object, so it's no go. I tried also to pass the invalid JSON as a string without any luck, since a string is also valid JSON (example below). Any ideas?</p>
  
  <pre><code>frisby.create('Ensure response has right status')
      .post('http://example.com/api/books', '{"invalid"}', {json: true})
      .expectStatus(400)
      .toss();
  </code></pre>