verdel / ipamcli

With this simple phpIPAM console client you can search, add, edit or remove record for IP entry in phpIPAM manager.
MIT License
1 stars 0 forks source link

JSONDecodeError #2

Open jrogers512 opened 1 year ago

jrogers512 commented 1 year ago

Any ideas what may cause this ?

phpIPAM IP address management [v1.4]

jrogers@util01:~/rancid$ python3 -V
Python 3.8.10
jrogers@util01:~/rancid$ pip3 list | grep "ipamcli"
ipamcli                0.0.8
jrogers@util01:~/rancid$ ipamcli search --ip 26.57.79.23
Traceback (most recent call last):
  File "/home/jrogers/.local/bin/ipamcli", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1134, in invoke
    Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/jrogers/.local/lib/python3.8/site-packages/ipamcli/cli.py", line 82, in cli
    ctx.token = get_token(ctx)
  File "/home/jrogers/.local/lib/python3.8/site-packages/ipamcli/libs/phpipam/client.py", line 79, in get_token
    elif r.status_code == 200 and r.json():
  File "/usr/lib/python3/dist-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
verdel commented 1 year ago

Unfortunately, I stopped using this tool at my current place of work. Therefore, I stopped keeping it up to date. I will try to make a test stand with the version of phpIPAM you specified in the near future and solve the problem.

verdel commented 1 year ago

I create local phpIPAM v1.4.7 deployment phpIPAM

Enable REST API in the phpIPAM settings and create app with name test api

After that I remove my work phpIPAM instance-specific code and publish v.0.0.9 of ipamcli.

Environment:

> python -V
Python 3.8.10

> pip -V
pip 23.2.1

> pip show ipamcli
Name: ipamcli
Version: 0.0.9

Here is small test: asciicast

This utility is rather a small example of how you can work with phpIPAM. I'm afraid that if you want to use it in your work, then you will have to modify it for yourself.