API Call Fails

  1. 4 weeks ago

    Trying to start using the CD API, but simply getting the token fails with the following code:

    import requests
    
    url = 'http://<x.x.x.x>/clonedeploy/api/token'
    params = {'grant_type': 'password', 'username': '<xxxxx>', 'password': '<xxxxx>'}
    
    headers = {'Content-Type': 'x-www-form-urlencoded'}
    req = requests.post(url=url, headers=headers, params=params)
    
    data = req.json()
    
    print(data)

    I've tried a password and Imaging Token, but the only thing I get back is:

    {"error":"unsupported_grant_type"}

    Any help is appreciated!

  2. Nevermind, I figured it out.
    grant_type etc. have to be in a payload, not params.

 

or Sign Up to reply!