Prev Previous Post   Next Post Next
Old 10-29-2020, 01:43 AM
Robert Hadfield's Avatar
Robert Hadfield Robert Hadfield is offline
Join Date: Oct 2020
Posts: 2
Default Powershell 7 JSON handling

Trying to update a product using powershell 7

I can get the product and convert it from JSON into an object in PS that I can work with:

$myproduct = ConvertFrom-Json (invoke-webrequest -uri
I can update an attribute:
$ = "Test Product 1.3"
I can convert it back to JSON:
$myJSON = ConvertTo-Json $myproduct -compress
But it fails on update:
$myJSON | Invoke-WebRequest -uri -method PUT -ContentType 'application/json'
With the following message:
InvalidOperation: The regular expression pattern media":{"images":["@{ is not valid.
The conversion of the media object one way or the other is messed up.

Comparing the Original:
to the Converted:
"media":{"images":["@{id=0; isMain=True; orderBy=0; image160pxUrl=; image400pxUrl=; image800pxUrl=; image1500pxUrl=; imageOriginalUrl=}"]}
You can see how different it is.

So I am trying to work out how to get around this.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:22 PM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.