Using API's with Powershell - Shopify

Christopher Jack 1,611 Reputation points
2021-04-07T15:48:31.937+00:00

Hi,

I am trying to get API's working with Powershell

I have the following code

$uri = "https://home-everything.myshopify.com/admin/api/2021-04/orders.json"
$apikey = "Username"
$password = "Password"
$headers = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($apikey+":"+$password))}
$products = Invoke-WebRequest -Uri $uri -contentType  "application/json" -Method   Get -Headers $headers | ConvertFrom-Json

However the error I am receiving is

Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try
again.

The URL I am trying to use that works in a browser is

https://username:Password@home-everything.myshopify.com/admin/api/2021-04/orders.json

Any help appreciated.. trying to get this to work.

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,361 questions
0 comments No comments
{count} votes

Accepted answer
  1. Christopher Jack 1,611 Reputation points
    2021-04-07T15:53:22.227+00:00

    Added -usebasicparsing and it seemed to resolve the issue

    $products = Invoke-WebRequest -Uri $uri -contentType  "application/json" -Method Get -Headers $headers -UseBasicParsing | ConvertFrom-Json 
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful