I am trying to send a request (POST) to an API using the XMLHTTP.6.0 object.
When running the same procedure in Postman it works like a charm - but when running it in VB over IIS (ASP) the responding server seems to not even receive the authorization headers specified.
Have been trying to figure out why this occurs all day without no luck.
Anyone have av idea why the Authorization header is no retreived by the remote server?
<%
Function ASPPostJSON(url)
Dim objXmlHttp
Set objXmlHttp = Server.CreateObject("Msxml2.XMLHTTP.6.0")
objXmlHttp.Open "POST", url, false, "nouser", "nopwd"
objXmlHttp.setRequestHeader "Accept", "*/*"
objXmlHttp.SetRequestHeader "Authorization", "Basic VGVzdEZpbmFuczpHUTJUR05KUUdFWURNTlJURzQzR0laUldHNVFXR1pSVA=="
objXmlHttp.SetRequestHeader "cache-control", "no-cache"
objXmlHttp.SetRequestHeader "content-length", "26"
objXmlHttp.SetRequestHeader "Content-Type", "application/json"
'send the json string to the API server
objXmlHttp.Send "{""PNR"": 194803234857 }"
'If objXmlHttp.Status = 200 Then
ASPPostJSON = CStr(objXmlHttp.ResponseText)
'end if
'return the response from the API server
Response.write(ASPPostJSON)
Set objXmlHttp = Nothing
End Function
'call the function and pass the API URL
call ASPPostJSON("https://api.testserver.com/v2/person")
%>