FGA API: 400 Bad Request "Invalid TupleKey.Object: Value does not Match Regex Pattern"

Overview

The FGA API endpoint “/stores/{store_id}/write” returned 400 Bad Request "invalid TupleKey.Object: value does not match regex pattern "^[^\\s]{2,256}$""

Cause

The value for the object should match the regex pattern "^[^\s]{2,256}" (White space is not allowed. The length is 2 to 256.)
The whitespace and/or the length of the value for the object violates the naming restriction.

Solution

Validate the payload before making a API call.