HTTP request using Deserialize JSON

Hi all, how do i perform a HTTP request using UiPath Request Builder Wizard and deserialization of the JSON data that has been extracted from the web portal.

The exercise will try to extract the player’s profile from the website NBA Players & Team Rosters | NBA.com

@Tengku_Aliff

first try in postman or so and you can copy the curl and import into http activity

for deserializing and all you have deserialize activity

cheers

GetResult.txt (714.2 KB)
I got the result but the response is really long. how do i get the players details based on the url?

@Tengku_Aliff

looks like you got whole page…what are you trying to do? any if it is not api why you want to use http request?

cheers

I have an assignment and this is the instructions,

*This assignment will require you to perform Http Request using UiPath Request Builder Wizard followed by Deserialization of the Json data you have extracted from the web portal. *
*Your main objective is to extract the player’s profile (basic data) from the website NBA Players & Team Rosters | NBA.com. *
Note that you are not restricted to extracting the data via json (recommended method, with high credit). There are many options you can opt for.

I am also not sure on how to do this since its not an API.

It seems like whoever wrote that doesn’t understand the topic. You wouldn’t use an HTTP Request to get data from that page. Just use Table Extraction.

True that would be the best way. I am confused as well on how to extract the details using http request and deserialize json

You wouldn’t. You can do an HTTP Request to that URL but what you’ll get back is XML (HTML) not JSON.

@Tengku_Aliff

after http request…the response can be converted to xml…but before that just to eliminate unused part I did a small strign manipulation…showing you extarcting one column…can follow same for all columns and write the data

Regex used in assign

System.Text.RegularExpressions.Regex.Match(str,"\<table.*\</table\>",RegexOptions.Singleline).Value - this extracts only table part

Now for loop use list item as xmldoc.Element("table").Element("tbody").Elements("tr") …here xmldoc is output of deserialize

inside loop used followign to get name…similarly find other column nodes and create a table

currentitem.Element("td").Element("a").elements("div")(1).Elements("p")(1).Value

or

currentitem.Descendants("p")(1).Value

Hope this helps

cheers

@Tengku_Aliff
we would interpret the assignment as open as you can decide on how to handle

  • table extraction / scrapping
  • Custom extracting logic
  • using API (which looks like it gets offered by NBA.com, others)

So it is up to you on what you decide

However we would point out:

  • HTML is NOT XML (XHTML only is XML)

    • e.g. empty tag / void tag (br, img…) will result to parsing exceptions
  • For HTML Parsing we suggest: https://html-agility-pack.net/

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.