I have a sample web API want to consume it in asp file, please guide me with the steps to consume web API in classic asp.
Asked
Active
Viewed 2,101 times
-1
-
1Show us what you've tried so far. – May 10 '19 at 10:27
-
You'll need to [use XHR](https://stackoverflow.com/a/37462944/692942) to make a request and handle the response. – user692942 May 10 '19 at 21:14
-
@Lankymart - I've never used WinHttpRequest before, does it have any advantages over Msxml2.XMLHTTP? – John May 11 '19 at 15:35
-
Thank you friends for your response. I'm able to consume the web api in classic asp. – RAM G May 14 '19 at 10:42
1 Answers
-1
Below is the asp code.
<%
Dim Id
Id = Request.QueryString("Id")
url = "http://localhost:50464/api/values/"+Id
Dim oXMLHttp
Set oXMLHttp=Server.Createobject("MSXML2.ServerXMLHTTP.6.0")
oXMLHttp.open "GET", url,false
oXMLHttp.setRequestHeader "Content-Type", "application/json"
oXMLHttp.send
response.write oXMLHttp.responseText
Set oXMLHttp = Nothing
%>
API url: http://localhost:50464/api/values

RAM G
- 50
- 1
- 1
- 13