Basic Group POST (Documentation exemple) don't work in python ...
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='[email protected]'), User(first_name='Jane', last_name='Doe', email='[email protected]')]
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 ?
@Lvdl-sec
before trying to print your group.id directly, can you show the “group” object returned by the server?
We're using the same script as you and it works fine, but we're using py3.9.