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

Updating Variant Price returns Error 400 Bad Request by Megan Crook

$
0
0

Hi,

Posting on behalf of the shop owner here. I'm trying to update the price of a variants (using PowerShell). No matter what I try I always get error 400. A stripped down simplified version of the code for debugging purposes (i.e. to target a single item) is:

    $key = "something"
    $pass = "goeshere"
    $webclient = new-object System.Net.WebClient
    $webclient.Credentials = new-object System.Net.NetworkCredential($key, $pass)

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

    $updateURL = "https://crooked-knitwear.myshopify.com/admin/variants/835371105.json"

    $putJSON = $webclient.UploadString($updateURL,"Put",$newPriceHereString)

I believe the JSON is constructed properly. I can certainly get data using the above format with PowerShell (although getting is merely a request for a URL rather than pushing anything up....). I've confirmed the variant is visible from a browser using the URL also.

Any ideas?

Many thanks :)


Viewing all articles
Browse latest Browse all 25503

Trending Articles