Solved

SQL: cURL calls::

Posted on 2013-06-20
7
2,009 Views
Last Modified: 2013-06-20
Hello team,

Is it possible to call cURL http/s calls from within sql server 2008 using TSQL?
> are there prerequisites and what are those
>do I need to install PHP or some client / modules/etc in order to run the curl command line statements
>what are pros and cons of using

One of our third parties have provided us with the API routines but before I start my questionings them wanted to get an idea from you guys first and see what you think.
thx

JohnE
0
Comment
Question by:John Esraelo
  • 3
  • 2
  • 2
7 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
While PHP has cURL builtin, there is also a command line version of cURL that you can install on your machine.  http://curl.haxx.se/  You do have to have one of them installed.  PHP requires a web server while cURL runs from the command line.  Come to think of it, you can run PHP from the command line too if you want to.

If you can run 'system' or 'exec' commands from TSQL, then you should be able to run either of those programs.
0
 
LVL 12

Expert Comment

by:adrian_brooks
Comment Utility
I'm sorry for sounding abrasive, but applications are responsible for communication between data stores...not the data stores themselves.

So, if your third party has provided you with an API, then they are expecting that you will create or have a supporting application in place that will provide the desired calls out to the remote service.

~AB
0
 

Author Comment

by:John Esraelo
Comment Utility
Adrian,
sql server can actually make an xp_cmdshell execution if I am not mistaken.  However, I am not sure about the rest of it and that is something that I would probably need to communicate with them, but, here today, I wanted to get a general thoughts here and collect knowledge.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:John Esraelo
Comment Utility
Dave,

I believe you are on the money.  I have tried something and did work in tsql. However, for some reason I am getting auth failure and working on that right now .
0
 

Author Closing Comment

by:John Esraelo
Comment Utility
Thank you Dave.
0
 
LVL 12

Expert Comment

by:adrian_brooks
Comment Utility
The only reason I stated what I did, was because database servers should be strictly just that. In a proper n-tier architecture, database servers should never take on the load of handling cross domain communications. Not even intra-domain communications, except in very limited circumstances.

The application layer is wholly responsible for all aspects of data transportation. Just because a database server supports that functionality certainly does not justify breaking best-practices in favor of using it.

I can understand SQL Server's ability to ACCEPT remote calls as the end result is a formatted dataset, but to make outgoing calls just totally goes against the grain of the intended design of a database server.

I wish you luck if this setup is to be used in any level of enterprise capacity.

~AB
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
I tend to agree with Adrian.  Although it is doable, I don't think it is a particularly good idea and I would always use cURL from my application, not my database.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now