I’m trying to utilize an API on a provider’s website to first get an Access Token and then using that token, execute another call to get a list of open items in their system.
Here is a link to the doc for the Access Token:
Authentication | Get an access token
Here is the link to the Get Open Items doc:
General | List a lab’s open cases
I’m testing this in the Script Console. Below is the code I’ve tested, but keep getting a 500 error:
client = system.net.httpClient()
url = 'https://staging.easyrxortho.com/sso/m.php/oauth2/access_token.php'
headers = {"grant_type": "client_credentials",
"client_id": "My_Client_Id",
"client_secret": "My_Client_Secret"}
response = client.post(url, headers=headers)
print response
The response returned from the above is:
<Response@1444923045 'https://staging.easyrxortho.com/sso/m.php/oauth2/access_token.php' [500]>
I’ve also tried converting the headers dictionary to a string and setting it as the params parameter in place of using the headers parameter.
That looked like this:
params = 'grant_type=client_credentials&'
params += 'client_id=_f7f055461271e6682c4656cf6f3511dfe55de81c68&'
params += 'client_secret=_9e1819a69216f2ce23c01319fa94daee4315b5ea85&'
and the post was essentially:
response = client.post(url, params=params)
That resulted in the the echoing back of the URL with the params values and still getting a 500 error.
I don’t think I’m following the documentation for the httpClient and calls correctly.
Can someone help me out with some more generic examples to send the values for grant_type, client_id, and client_secret in a API call for this website?
Thanks!