Search code examples
pythonrestpython-2.7urllibyodlee

How to enforce GET request using urllib.urlopen?


account_summary_API_url = "https://rest.developer.yodlee.com/services/srest/restserver/v1.0/account/summary/all"

account_summary_params = urllib.urlencode({'cobrandSessionToken':cobSessionToken,'userSessionToken':userSessionToken})

account_summary_response = urllib.urlopen(account_summary_API_url,account_summary_params).read()

I am using above url then encoded params to call the API but this API needs to be called with GET method . How do I enforce that ?


Solution

  • urllib.urlopen("http://yoururl.com/?%s" % your_url_encoded_params)
    

    Passing the params by way of the url makes this a GET request.

    So:

    account_summary_response = urllib.urlopen("%s?%s" % (account_summary_API_url,account_summary_params)).read()