Access API from Stored Procedure in SQL Server
This document describes how to call any API with POST, GET,
PUT and DELETE methods from stored procedure. For example, if we want to send
email from SQL Server using stored procedure but don’t want to use inbuild
functionality of SQL Server but to use any third party API.
To make it working (For the purpose of testing) first I
created API you can get the API of GET and POST http://mongobox.azurewebsites.net/swagger
Now created a CLI Project in Visual Studio and created a
method called SendMail which is
accepting few parameters like WebURL, EmailTo,EmailBody,EmailSubject. See below
image.
Now as I am utilizing the POST method API, so I need to pass
various parameters in that API and I am passing it to API with given method:
(Name, Age and other params are according to API we can use any params as per
need of API)
Now, I need to build and publish this code in folder to get
DLL file which will be used as assembly file in SQL server see below image (We
need to add other dependent DLLs as well.)
Now created a Stored Procedure as
To call this stored procedure use below syntax:
Comments
Post a Comment