Getting Encrypted Response from Invoke-RestMethod

0
10
Asked By CuriousCat42 On

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

Answered By CodeWhisperer81 On

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.

Answered By TechGuru99 On

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!

Answered By DataDude23 On

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!

CuriousCat42 -

Thanks for the tip! I'll try using the WebRequestSession method and see if that works.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.