Question: I want to be able to randomize click events on buttons in a list of items. I have seen similar code for adding classes, but I need to simulate random click events over the list of items. 

```js
$(function() {
  $("button").click(function() {
    $(this).toggleClass("active");
  });
  $(".item").each(function(i, e) {
    var button = $(this).find("button");
    ranNum = Math.floor(Math.random() * (6 - 2 + 1)) + 2;
    if ((i + 1) % ranNum == 0) {
      $(e).button.click();
    }
  });
});
```

```css
.active {
  background: green
}
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="item">
  <button>Button 1</button>
</div>
<div class="item">
  <button>Button 2</button>
</div>
<div class="item">
  <button>Button 3</button>
</div>
```

Answer: 
I think that the "plain" **400 Bad Request** should be enough (and the details should be expressed in the response body instead).

From Wikipedia:

> 
> **400 Bad Request**  
> 
>  The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, size too large, invalid request message framing, or deceptive request routing).
> 
> 
> 

The "malformed request syntax" part suits your case perfectly (since sending integers instead of strings (GUIDs) does not comply to the request schema and subsequently its syntax).

So, your API should return a response like this:

```
{"message": "Error processing element at index 8: a string GUID expected, integer '13' found"}

```

Update: If indeed only the GUIDs were sent, just return 200. The 206 code is for very different purpose (e.g. multithreaded downloading), when only a part of the (usually binary) response was delivered. In your case, the returned response is complete, even it contains only the GUIDs.
> 
> Suggested HTTP status code for specific API scenario?
> 
> 
> 

Keep in mind that status codes belong to the "transport documents over a network" domain; they are meta data in a standardized form so that general purpose components can recognize the semantics and act.

If you are using a `GET`, then presumably the IDs are encoded into the URI (the message-body of a request doesn't have any defined semantics when the method is `GET`). If the data is encoded into the URI, then it is part of the resource identifier.

If the resource identifier is ill formed, and you cannot provide a representation for the resource in question, the standard status-code to use is [404](https://www.rfc-editor.org/rfc/rfc7231#section-6.5.4)

> 
> The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
> 
> 
> 

Broadly, you are indicating to the client that there is a problem with the request and that the problematic part of the request is the target-uri. Normally, we would include in the message-body of the response more context specific information.

> 
> 422 Unprocessable Entity ... looks to be more for formatting of the response.
> 
> 
> 

[422](https://www.rfc-editor.org/rfc/rfc4918#section-11.2), like all 4xx status-codes, describes a problem in the request -- specifically that there is a semantic problem with the message-body of the request. This one is clearly appropriate to use with requests that include a message-body, including POST, PUT, PATCH and so on; it's not obviously appropriate for GET.