Steps to get data from API using powershell from server

PATEL Prashant Kumar 20 Reputation points
2024-05-13T00:52:15.48+00:00

Hi,

I want to call an API from the server using PowerShell script and token.
I tried with myself but getting SSL/TLS related error.
Please provide the steps and script.

Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,407 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,111 Reputation points
    2024-05-13T15:09:48.82+00:00

    Try placing this code at the beginning of your script:

    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
    

    You may have to use "Tls13". It depends on the host you're connecting to.

    0 comments No comments