gophish / api-client-python

A Python API Client for Gophish
MIT License
44 stars 48 forks source link

Basic Group POST (Documentation exemple) don't work in python ... #42

Open Lvdl-sec opened 4 months ago

Lvdl-sec commented 4 months ago

Gophish Version : 0.12.1 Gophish Python API Version : 0.5.1 Python Version: 3.11

If i try the basic exemple with my server `from gophish import Gophish from gophish.models import *

api_key = 'MyKey' api_srv = 'https://MyServer/api'

api = Gophish(api_key, host=api_srv)

targets = [ User(first_name='John', last_name='Doe', email='johndoe@example.com'), User(first_name='Jane', last_name='Doe', email='janedoe@example.com')]

group = Group(name='Doe Company', targets=targets) group = api.groups.post(group) print (group.id)`

I get the following error: Traceback (most recent call last): File "/home/notme/scripts/TestApi.py", line 14, in <module> group = api.groups.post(group) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/gophish/api/groups.py", line 15, in post return super(API, self).post(group) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/gophish/api/api.py", line 106, in post raise Error.parse(response.json()) ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 525, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 375, in decode raise JSONDecodeError("Extra data", s, end, len(s)) simplejson.errors.JSONDecodeError: Extra data: line 1 column 5 - line 2 column 1 (char 4 - 19)

Is there any wrong with the example or with the API ?