API Bulk Add Reference Set Using Powershell

Hi,

I’m wondering if anyone would happen to know the correct syntax for bulk adding IP addresses to a reference set using the API and PowerShell? I can add individual items no problem, but I can’t seem to get the body correct for bulk additions. I’ve tried many different formats for the body variable/array, but I keep getting the same error:

“Invoke-RestMethod : {“message”:”Request body must be populated for body parameter “data””,”details”:{},”description”:””,”code”:10,”http_response”:{“message”:”The request
was well-formed but was unable to be followed due to semantic errors”,”code”:422}}”

Here’s an example of the code I’m using:

$apiKey = “XXXXXXXXXXXXXXXXXXXXXX”
$url = “https://X.X.com”
$URI = “https://X.X.com/api/reference_data/sets/bulk_load/APITest”

Invoke-RestMethod -Method Post -Uri $URI -Body (convertto-json $body) -Header @{“SEC”= $apiKey }

$body = @{“10.10.1.5″,”10.10.1.5″,”50.50.50.50″,”123.45.6.7”}

Related:

Leave a Reply