Quantcast
Channel: Opinion: Shopify Community - Shopify APIs & SDKs
Viewing all articles
Browse latest Browse all 25503

Megan Crook commented on [Solved] Updating Variant Price returns Error 400 Bad Request

$
0
0

I had initially used Invoke-Webrequest but this failed. Once I realised the api key and password needed to be encoded in the header rather than passed in the URi I was able to solve both getting the data and updating it. For completeness and to help anyone else:

$apikey = "something"
$password = "goeshere"
$headers = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($apikey+":"+$password))}

$newPriceHereString = @"
{"variant": {"id": 835371105,"price": "96.00"
    }
}"@

$updateURi = "https://anewshop.myshopify.com/admin/variants/835371105.json"

$updateRequest = Invoke-WebRequest -Uri $updateURi -contentType "application/json" -Method Put -Headers $headers -Body $newPriceHereString

 


Viewing all articles
Browse latest Browse all 25503

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>