Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request is not valid #7

Open
gpipito opened this issue Jun 9, 2020 · 2 comments
Open

Request is not valid #7

gpipito opened this issue Jun 9, 2020 · 2 comments

Comments

@gpipito
Copy link

gpipito commented Jun 9, 2020

Hi,

I wrote a very basic code but it always game code 400, request is not valid:

from phpipam_client import PhpIpamClient, GET

ipam = PhpIpamClient(
        url='https://myurl.local',
        app_id='myapp',
        token='ipam_provided_appcode',
        encryption=True,
)

response=ipam.get('/devices/')
print (response)

I tried the same with a basic rest script and it works fine:

import requests
import json

app='myapp'
appCode='ipam_provided_appcode'
controller=input('Type the controller to perform the search: [subnets|addresses]\n ')
action='search'
    
if controller == ('subnets' or 'addresses'):
        target=input('Type the IP address/subnet to search\n ')
        url=f'https://myurl/api/{app}/{controller}/{action}/{target}/'
        response = requests.get(url, headers={
            "token": appCode,
        })

        response = (response.json())
        print (json.dumps(response, indent=4))
   
else:
        print ('Error: invalid target\n')

What am I doing wrong?

phpipam_client 0.4.0
python 3.6.8

@dagbdagb
Copy link

Good. Then it isn't just me. Seeing the same.
Python 3.7.7
phpipam-client 0.4.0

Tried playing with the url as well, but no go,

@hyperpouet
Copy link

I'm also here, sharing my founds:

python 3.8
phpipam from master branch
phpipam-client 0.4.0

using the @gpipito code example as test

  • If phpipam UI -> Administration -> API -> App security = Encrypted

in phpipam, config.php with $api_crypt_encryption_library = "mcrypt";
and it works.

no changes needed in config.php (default to openssl)
and in phpipam-client, just by commenting the section below in client.py (quick way to test):

    #if not self._api_encryption:
    #    self.login()

changing the parameter encryption to False in the code, and it works also.

hope it could help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants