This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I am brand new to PowerShell, but I can already tell it will be a powerful tool and worth my time to learn. Unfortunately I am also new to using web API's, so this has been a tough project for me. After many hours of searching, I am waving the white flag and asking for help.
I am trying to download a CSV from Teamwork Projects that shows time entries. Here is what I have so far:
$pair = "username:pass"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$resource = "https://[myURL].teamwork.com/time_entries.json"
$json = Invoke-RestMethod -Uri $resource -Method Get -Headers $headers
$json
Up until this point, everything works. I get a response that looks right. However, when I try to export to CSV or parse it to something useful, I either get failures or just the "Status" header record.
Adding this gives me a CSV with the status information:
$json | Export-csv -delimiter ',' -Path C:\Test.csv
I emailed support and this is what they told me:
It looks like you're connecting to the API and getting an OK status response. You should also be getting your time entries in the time-entries object.
I checked your account and there are time entries there so it should be fine.
It seems like you're parsing the 'status' object and getting its value of 'ok', are you parsing the 'time_entries' object too?
I don't know how to specify which object to parse. I have tried several variations of ConvertFrom-JSON and I always get an error about "invalid json primitive" which I suspect is because it is receiving two objects instead of the expected one.
Here is the product specific API info
Any suggestions would be much appreciated!
Subreddit
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...