Forum Discussion

AlexisMoniot's avatar
AlexisMoniot
New Contributor
2 years ago

Use UUID requests in python

Hi everybody, 

I 'm new user with swagger and a I have a issue with this requests

I try this : 

       params = {"CNX": "CNX", "Identifiant": "USER", "MotDePasse": "MyPW"}
       response = requests.post(api_url, json=params)
       responseJSON = response.json()
       UUID = responseJSON['UUID']
I have my UUID but when I want to use it, not working : 
example : 
       api_url_Doc = "https://MyURL/api/v1/sessions/dossier"
       params = {"CNX": "CNX", "UUID": UUID}
        response = requests.get(api_url_Doc, json=params)
        responseJSON = response.json()
 
Always same response, then a try to use UUID with all operators. I seems to be with UUID but it works with the swagger interface testing... 
        <Response [500]>
       {u'Message': u'Une erreur s\u2019est produite.'}

 

thks

1 Reply

  • I tried with curl but same result ... 

     

    import pycurl

    from urllib.parse import urlencode

    c = pycurl.Curl()

    c.setopt(c.URL, 'https://MyURL/api/v1/sessions/dossier/022790')

    post_data={'CNX':'CNX', 'UUID':UUID}

    postfields=urlencode(post_data)

    c.setopt(c.POSTFIELDS, postfields)

    c.perform()

    print('Response code: %d' % c.getinfo(c.RESPONSE_CODE))

    c.close()

     

    >>> Response code: 400