In this post we will see simple technique to call REST API which requires Two step process to call API using ODBC Driver for API.
- Call login method to get temporary token
- Call API request using Temp Session Token issued in previous step (Request new token if its expired)
Here is an example of some 3rd party API which requires login method
You need to use DynamicToken method in your case. Basically you first get new token and then use
Log in (create a new session):
POST https://api.enevo.com/api/3/session
{ "username": "user@company.com", "password": "somePassword123" }
and then use Token to call various operations GET / POST
Retrieve an up-to-date description of the state of a particular site:
X-Token: [session token]
GET https://api.enevo.com/api/3/site/2818
Create a new site:
X-Token: [session token]
POST https://api.enevo.com/api/3/site
{
"type": 1,
"name": "Annex 3",
"address": "281 S Lake Blvd.",
"city": "Greentown",
"country": "USA",
"latitude": 63.2913,
"longitude": -19.8822,
"customerKey": "8134a927e15"
}
Here is your SQL Query using our driver
SELECT * FROM $
WITH(
Src='https://api.enevo.com/api/3/reportTypes
'
,DataConnectionType='HTTP'
,AuthScheme='{none}'
,TokenUrl='https://api.enevo.com/api/3/session
'
,TokenRequestData='{ "username": "[$userid$]", "password": "[$password$]" }
' ,TokenRequestMethod='POST'
,TokenResponseContentFilter='$.session.token'
,TokenRequestHeaders='Content-Type:application/json'
,TokenResponseContentType='Json'
,UserName='MyUser001' --//**** change this ***
,Password='P@$$w0rdAAc12' --//**** change this ***
,CredentialType='TokenDynamic'
,Filter='$.reportTypes[*]' --//**** each response may have different structure so change this ***
--,RequestData='*** body for post request *****'
,RequestMethod='GET'
)
Contact Us
If you have more question(s) feel free to contact us via Live chat or email to support@zappysys.com
Comments
0 comments
Please sign in to leave a comment.