Adding a field to JSON result set from an API call?

How would I go about including the Visit.data.id into the Visit Route results?

Visit = Invoke-WebRequest -Uri https://url/26t85y6zJs2M1TubhUQuuc_vBivj67PaoCQvajyRJYyBJ/visits?start_date='20180516'"&"end_date='20180517'"&"page[size]=100 -Header @{ Authorization = "Token token="+"TOKEN" } -ContentType "application/json" | ConvertFrom-Json | Select-Object -ExpandProperty data | ConvertTo-Csv -NoTypeInformation | Set-Content D:TempAPIvisits.csv # 

Results – “id”,”type”,”attributes”

Visit Route = Invoke-WebRequest -Uri https://url/26t85y6zJs2M1TubhUQuuc_vBivj67PaoCQvajyRJYyBJ/visits?start_date='20180516'"&"end_date='20180517'"&"page[size]=100 -Header @{ Authorization = "Token token="+"TOKEN" } -ContentType "application/json" | ConvertFrom-Json | Select-Object -ExpandProperty data | Select-Object -ExpandProperty attributes | Select-Object -ExpandProperty visit_route | ConvertTo-Csv -NoTypeInformation | Set-Content D:TempAPIvisits_route.csv 

Results – “hostname”,”page_path”,”previous_page_path”,”time_on_page”,”page_title”,”page_url”,”display_page_name”

What I would like returned is – “id”,”hostname”,”page_path”,”previous_page_path”,”time_on_page”,”page_title”,”page_url”,”display_page_name”

Or am I going about this completely wrong !?

submitted by /u/arejaytee
[link] [comments]

Leave a Reply