4

I want to send an HTTP GET call to an API every hour. I want this data directed to my SQL Server database (or MySQL). I'm a data guy, not a web developer.

Is it possible to make this call using SQL Server? If so, how? If not, what's the easiest workaround?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ColinMac
  • 620
  • 2
  • 9
  • 18
  • 1
    https://stackoverflow.com/questions/5983599/can-sql-server-send-a-web-request – Chris Lam Jun 09 '17 at 04:21
  • 2
    Yes you can. Refer to : https://stackoverflow.com/questions/22067593/calling-an-api-from-sql-server-stored-procedure – Sujith Jun 09 '17 at 04:41
  • Possible Duplicate of https://stackoverflow.com/questions/22067593/calling-an-api-from-sql-server-stored-procedure/72395955#72395955 – ZappySys Jun 01 '22 at 15:25

1 Answers1

10

Sure it's as simple as this;

     exec  [dbo].[APICaller_POST]
     @URL = 'http://localhost:5000/api/auth/login'
     ,@BodyJson = '{"Username":"gdiaz","Password":"password"}'

After you deploy this CLR Stored procedure: https://github.com/geral2/SQL-APIConsumer

It has multiple procedures that allows you calling API that required a parameters or even passing multiples headers and tokens authentications.

enter image description here enter image description here

Geraldo Diaz
  • 346
  • 5
  • 7