You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
905 B
24 lines
905 B
# __author__ = 'bdm4' [oauth example code came from this author] |
|
# prototyping script for LibAnswers/LibWizard POST/API program |
|
|
|
import requests, json |
|
|
|
token_url = "https://uis.libanswers.com/api/1.1/oauth/token" |
|
|
|
test_api_url = "https://uis.libanswers.com/api/1.1/ticket/create" |
|
|
|
client_id = <id> |
|
client_secret = <secret> |
|
|
|
data = {'grant_type': 'client_credentials'} |
|
|
|
access_token_response = requests.post(token_url, data=data, verify=True, allow_redirects=False, auth=(client_id, client_secret)) |
|
|
|
tokens = json.loads(access_token_response.text) |
|
|
|
api_call_headers = {'Authorization': 'Bearer ' + tokens['access_token']} |
|
post_data = {'quid':'5231', 'pquestion': 'test_pquestion', 'pdetails':'test_pdetails', 'pname':'test_pname', 'pemail':'test_pemail', 'ip':'test_ip'} |
|
api_call_response = requests.post(test_api_url, headers=api_call_headers, verify=True, data=post_data) |
|
|
|
print(api_call_response.text) |
|
|
|
|