Issue
My request works fine when using urllib2, but I get a 403 error when using requests instead.
import urllib2
url = 'https://api.optconnect.com/summit/beta/accounts/login/app_secret'
data = {'accountId': 000,
'applicationId': 000,
'secret': '000'}
data = json.dumps(data)
headers = {'accept': 'application/json', 'content-type': 'application/json' }
req = urllib2.Request(url, data ,headers)
response = urllib2.urlopen(req)
print(response.getcode())
200
import requests
url = 'https://api.optconnect.com/summit/beta/accounts/login/app_secret'
data = {'accountId': 000,
'applicationId': 000,
'secret': '000'}
data = json.dumps(data)
headers = {'accept': 'application/json', 'content-type': 'application/json' }
req = requests.get(url=url, data=data, headers=headers)
print(req.status_code)
403
Solution
The following worked
req = requests.request("POST", url=url, data=data, headers=headers)
Answered By - rose
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.