Unable to upload Virtual Background using API

I’ve searched the history on the DevForum, but I can’t quite find a topic that matches what I’m looking for.

I’m having difficulty in using the “Upload Virtual Background Files” API at the Groups level.
Endpoint: /groups/{groupID}/settings/virtual_backgrounds

I’m not sure I’m formatting the request body quite correctly.
Is there any guidance on what it should look like?

The reference docs say that it should be “file” with the format of multipart/form-data, but me trying to create this doesn’t work:

body=@{‘file’ = “/path/to/file”}

This returns as:
Name Value

file /path/to/file

I’m using powershell to write the API calls, but used to converting tables into JSON objects etc for PATCH calls, and that works fine.

Any help is much appreciated!

Update: I’ve managed to get this to work in Postman, and done some more digging on why it’s not working on Powershell.

So far I’ve found that I should be using the -Form switch on the Invoke-RestMethod command, but this was introduced in Powershell 6.1.0, so I need to use Powershell Core, rather than Windows Powershell (which has a ceiling of 5.1)

Hi @philip.ross thanks so much for sharing how you resolved!

Okay - found this article:

Looks that it might be possible to do it manually with Windows Powershell, but I’ve taken the ‘easy option’ and started to use the latest versions of Powershell Core, so the OOTB functionality is now available.
This is also probably worthwhile as means I can use recent features across other API endpoints, and APIs for other applications.

Confirmed that installing Powershell Core and then using the -Form parameter does work and upload the image successfully.