anancarv/python-artifactory

Error on user update

Tioborto opened this issue · 0 comments

Describe the bug
Object of type datetime is not JSON serializable

To Reproduce
Update a user groups
Stacktrace :

Object of type datetime is not JSON serializable
Traceback (most recent call last):
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/flaskit/resource.py", line 363, in wrapped
    r = function(*args, **kwargs)
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/resources/ArtifactoryTeamMembersSyncPut.py", line 77, in ArtifactoryTeamMembersSyncPut
    user = artifactory_client.users.update(existing_user)
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/pyartifactory/objects.py", line 201, in update
    self._post(f"api/{self._uri}/{username}", json=user.dict())
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/pyartifactory/objects.py", line 104, in _post
    return self._generic_http_method_request("post", route, **kwargs)
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/pyartifactory/objects.py", line 133, in _generic_http_method_request
    response: Response = http_method(
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/requests/sessions.py", line 452, in prepare_request
    p.prepare(
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/requests/models.py", line 316, in prepare
    self.prepare_body(data, files, json)
  File "/Users/alexandre/Clients/Adeo/Github/software-factory--self-service-api/.venv/lib/python3.8/site-packages/requests/models.py", line 466, in prepare_body
    body = complexjson.dumps(json)
  File "/Users/alexandre/.pyenv/versions/3.8.2/lib/python3.8/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/alexandre/.pyenv/versions/3.8.2/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/alexandre/.pyenv/versions/3.8.2/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/Users/alexandre/.pyenv/versions/3.8.2/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
Error executing API ArtifactoryTeamMembersSyncPut (Object of type datetime is not JSON serializable)

Environment:

  • pyartifactory version : 1.7.0
  • Python version : 3.8.2