skip to Main Content

Python call Powershell Invoke-RestMethod with Json as string into Body

import requests import subprocess import base64 credentials = "login:password" url = f'urlXXXurl' body = '{"id": 4986986, "key": "2df534ee-270b-4ab4-83fb-1b308febacce", ...}' headers = '"""@{Authorization = 'Basic %s'}"""' % base64.b64encode(credentials.encode("ascii")).decode("ascii") command = 'powershell.exe Invoke-RestMethod -Method Post -Uri %s -ContentType application/json -Body """%s""" -Headers…

VIEW QUESTION
Back To Top
Search