Forum Discussion

samithak's avatar
samithak
New Contributor
9 years ago

I'm trying to access HTTP header information when website POST or GET.Request send in JSON format.

Hi All,

I'm trying to access HTTP header information when website do a POST or GET.Request send in JSON format. on POST request I can see all required information under Network-->Headers-->Request Payload (using chrome dev tool) but I canno't figure it out how to read these information using Testcomplete (use TC 11.1).

I tried with following way but was not success.
var page = Sys.Browser("Chrome").Page(baseurl & format=json");
var http1 = page.contentDocument

 

Information what I need to read highlighted in attached screen.


Please let me know if you have any solution. Thanks in advance.

 

Thanks

-Sam

8 Replies

  • Headers are a property of the HTTP object. Not something you can access directly from TC as standard as far as I know.

     

    You can create your own HTTP object in script:

     

    https://msdn.microsoft.com/en-us/library/ms766431(v=vs.85).aspx

     

    Set the body and header properties of that and interrogate the body and header of the response. If it's sending JSON back and forth, sounds more like a webservice you're dealing with.

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Tanya - does that work with JSON? All the ref material seems to refer to XML?

         

        Just that to get the response, he'll probaby have to generate the request himself as well, and it sounds like it's using JSON. I know the MS ServerXMLHTTP object I linked to above handles JSON just fine, despite the name (and lack of any mention of JSON in the docs for it).