Query web API and return JSON data

Copper Contributor
curl -X GET "https://api.server.com/v1/markets/quotes?symbols=AAPL,VXX190517P00016000&greeks=false" \
     -H 'Authorization: Bearer <TOKEN>' \
     -H 'Accept: application/json'

How do i run this Rest Json API in sql server directly ? 


I believe its a combination of using he below, but i could not figure out the last syntax.

sp_OACreate,
sp_OAMethod
sp_OAGetProperty

 Python version is here : 

# Version 3.6.1    import requests

response = requests.get('https://api.server.com/v1/markets/quotes', 
params={'symbols': 'AAPL,VXX190517P00016000', 'greeks': 'false'},
headers={'Authorization': 'Bearer <TOKEN>', 'Accept': 'application/json'} )
json_response = response.json()
print(response.status_code)
print(json_response)

 

1 Reply

@DavidPais , yes, sp_OACreate and the other system procedures is a possible way to go, see

OLE Automation stored procedures (Transact-SQL) - SQL Server | Microsoft Learn

 

But believe, you don't want that, it's more the painfull programming.

Better use scripts like PowerShell or a simple C# application.