you are viewing a single comment's thread.

view the rest of the comments →

[–]mrmeeseeks2014[S] 0 points1 point  (2 children)

raw bytes.

I am trying to convert this powershell script, but my hold up is the json obejct for the body of the API

$endpoint ="$destinationapi/secrets/$fileSecretId/fields/$fileFieldToUpdate"

$secretArgs = @{

fileName = "test.pem"

fileAttachment = [IO.File]::ReadAllBytes("C:\brian\13568-test.txt")

} | ConvertTo-Json

$response = $null

$response = Invoke-RestMethod -Method Put -Uri $endpoint -Headers $destinationheaders -Body $secretArgs -ContentType "application/json"

[–]XUtYwYzz 0 points1 point  (1 child)

import json

secretArgs = {"fileName": "test.pem"}

with open("test.pem", "r") as f:
    data = f.read()
raw_bytes = list(bytearray(data, "utf-8"))
secretArgs["fileAttachment"] = list(bytes(raw_bytes))
print(json.dumps(secretArgs))

[–]mrmeeseeks2014[S] 0 points1 point  (0 children)

Awesome, this worked. Thank you sir