Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?

You’ll need to look at the server side logs to see what’s actually causing the 400. Without this, it’s just conjecture. With it, you should see exactly what’s causing the problem.

However, I conjecture that you’re lacking authentication headers, or an authentication request. I’m not seeing anything related to authentication in your AJAX request, and anything POST’ing to admin-ajax.php probably should prove it’s an admin first. Take a look at this:

How do I correctly setup an AJAX nonce for WordPress REST API? . You’ll probably need to adjust it a bit, since it looks like they’re using a public endpoint that wants user authentication, while you’re using an admin endpoint, but in either case you need some sort of authentication (by default.)