Saturday 15 March 2014

asp classic - How do I Access Response Header in Http Request -


I am calling an external API. This data, annoyingly, is in the title (text response is empty)

How do I use the header of the response?

This is what I am trying to:

  Smooth httpRequest, postResponse set httpRequest = Server.CreateObject ("MSXML2.ServerXMLHTTP") httpRequest.Open "POST" , "Http: //www.api.com", false, "un", "pw" httpRequest.SetRequestHeader "content type", "app / jason" httpRequest.setRequestHeader "content-length", lane (jsondata) httpRequest .Send data if httpRequest.status = 200 then react. Type httpRequest.getResponseHeader response.write httpRequest.ResponseText if set httpRequest = nothing   

but it gives me:

  msxml3.dll error ' 80072f76 'The requested header was not found.   

And a bonus question: I just saw the "XML" section of "MSXML2.ServerXMLHTTP" - am I using it the right protocol? It always works for straightforward positions and gets so far.

You must specify the name you want to retrieve:

  feedback. Type httpRequest.getResponseHeader ("SomeHeaderName")   

There is not a single response header. There may be several standard response headers such as content-type and You may also have custom titles.

And a bonus question: I just saw the "XML" section "MSXML2.ServerXMLHTTP" - Am I using the correct protocol?

Yes, of course, this is the right COM object to use from the classic ASP application to send HTTP requests.

No comments:

Post a Comment