We help IT Professionals succeed at work.
Get Started

Curious how Expert Awards are earned? Find out on this week's podcast, featuring Experts Exchange CEO Randy Redberg.Listen Now

Troubleshooting Question

Passing Curl data through ServerXMLHTTP in Classic ASP

Last Modified: 2020-11-16
One of my service providers changed their APIs and I need to generate a key rather than using username and password. They allow the output to be in XML, but are requiring the credentials to be passed in Curl. It's easy enough in their dev environment, and here is what they tell me I need as a command:

  • curl -X POST "https://api.XXXXX.com/api/v1/users/login.xml" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{\"user\":{\"email\":\"XXXXX\",\"password\":\"XXXXX\",\"remember_me\":\"true\"}}"
I did a fair amount of research, and came up with passing information through either WinHTTP or MSXML2 server object. The GET works like a charm to return XML, but can't seem to pass information through the post. Here's what I've done so far:

szData="{\" & Chr(34) & "user\" & Chr(34) & ":{\" & Chr(34) & "email\" & Chr(34) & ":\" & Chr(34) & "XXXXXX\" & Chr(34) & ",\" & Chr(34) & "password\" & Chr(34) & ":\" & Chr(34) & "XXXXXX\" & Chr(34) & ",\" & Chr(34) & "remember_me\" & Chr(34) & ":\" & Chr(34) & "true\" & Chr(34) & "}}"
if bTest then fpTest.WriteLine(szData)
Set objToken = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
With objToken
    Call .Open("POST", "https://api.XXXXXX.com/api/v1/users/login.xml", False)
    Call .SetRequestHeader("accept", "application/json")
    Call .SetRequestHeader("Content-Type", "application/json")
    Call .Send(Chr(34) & szData & Chr(34))
End With
if bTest then fpTest.Write(objToken.responseText)

Here's what was written to the output file:


<?xml version="1.0" encoding="UTF-8"?>
  <user type="array">
    <user>can't be blank</user>

Using the syntax using the Chr(34) for the quote marks got me in the door, but not sure how to get any further.

I am open to any suggestions. This is part of a large legacy system (about 20 years old), so I can't rewrite in PHP or do anything drastic. The good news is I have access to the web server (Windows Server 2012 R2).

Hoping for responses other than "you're screwed".

Rob Bristow
Classic Club Solutions, LLC

Watch Question
Chief Technology Officer
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE