docs: def encode_params(self, data=None, **kwargs):
          """
          Build the body for a application/json request.
          """
          if isinstance(data, basestring):
              raise ValueError("Data must not be a string.")
          if data is None:
              return b"", self.content_type
  
          fields = to_key_val_dict(data or "")
          try:
              body = json.dumps(fields)
          except:
              body = json.dumps(fields, encoding='latin-1')
  
          return str(body).encode(), self.content_type