Forum Discussion
Hi,
You've posted this in the ReadyAPI forum instead of the TestComplete forum. I haven't used TestComplete, but I've done a reasonable amount of Javascript.
The first first I would hone in on are these lines....
Log.Message(aqHttpResponse.StatusCode); // A status code
Log.Message(aqHttpResponse.StatusText); // A status text
Log.Message(aqHttpResponse.Text); // A response body
Did you get a 200 for status code? Did you get a response? Apologies if you know all this already. If you got a 200, you know the service call worked. If you can see that response body in the logs, then it probably is the orange line.
What I cannot tell from the example is whether the service call is asynchronous or synchronous (have a Google on "javascript Fetch API"). It might be that you need to 'await' the response before trying to log it.
Lastly, JSON is case-sensitive and quite often data is stored within an array. If you see the data you want to access in square brackets, you need to access it slightly differently. If you could post an excerpt of the JSON, I might be able to help. Beyond that, heopfully someone with more TestComplete experience will be able to reply.
- david-beltran3 years agoOccasional Contributor
I'm using a MLB API for the time being instead of the API for our billing site. I wanted to make sure it could be done before I worked on trying to make it work with our expected data. The JSON data I received was:
{"search_player_all":{"copyRight":" Copyright 2022 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt ","queryResults":{"created":"2022-05-25T21:28:12","totalSize":"1","row":{"position":"2B","birth_country":"USA","weight":"195","birth_state":"CA","name_display_first_last":"Jeff McNeil","college":"Long Beach State","height_inches":"1","name_display_roster":"McNeil","sport_code":"mlb","bats":"L","name_first":"Jeff","team_code":"nyn","birth_city":"Santa Barbara","height_feet":"6","pro_debut_date":"2018-07-24T00:00:00","team_full":"New York Mets","team_abbrev":"NYM","birth_date":"1992-04-08T00:00:00","throws":"R","league":"NL","name_display_last_first":"McNeil, Jeff","position_id":"4","high_school":"Nipomo, CA","name_use":"Jeff","player_id":"643446","name_last":"McNeil","team_id":"121","service_years":"","active_sw":"Y"}}}}