Hey everyone! I'm trying to fetch response data from a website using PowerShell's Invoke-RestMethod, but I'm running into an issue where the response appears encrypted. I can see the data just fine when I visit the link in my browser. Here's the link I'm working with: api.doctena.lu/agendaAvailabilities/7690d723-4b61-49db-b329-38168e3839e2?language=nl&from=1747951201&to=1748383199&reason=151888&weight=front_search_change_date&showMessageNotification=false.
I want to retrieve that data in PowerShell for use, but it doesn't seem to work. Any ideas on why this is happening? Thanks in advance!
3 Answers
What do you mean by 'encrypted'? Could you share the output you're getting? It might be an issue with how the request is being sent.
I had a similar problem, but it worked for me using the command: `irm "https://api.doctena.lu/agendaAvailabilities/7690d723-4b61-49db-b329-38168e3839e2?language=nl&from=1747951201&to=1748383199&reason=151888&weight=front_search_change_date&showMessageNotification=false" -Headers @{Accept="application/json"}`. Might give that a shot!
I recommend using a WebRequestSession to mimic a browser request. Here’s how you can do it:
```powershell
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0"
Invoke-WebRequest -UseBasicParsing -Uri "https://api.doctena.lu/agendaAvailabilities/7690d723-4b61-49db-b329-38168e3839e2?language=nl&from=1747951201&to=1748383199&reason=151888&weight=front_search_change_date&showMessageNotification=false" -WebSession $session -Headers @{...}
```
This approach should help you bypass any encryption issues!
Thanks for the tip! I'll try using the WebRequestSession method and see if that works.