Skip to content

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

@Lvdl-sec

Description

@Lvdl-sec

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions