REST API description: Difference between revisions

No edit summary
Line 39: Line 39:
Invoke-RestMethod on the PowerShell needs a few parameters for the access of the Allegro Network Multimeter:
Invoke-RestMethod on the PowerShell needs a few parameters for the access of the Allegro Network Multimeter:


To set the user name for basic authorization, use the '''-Headers''' parameter
To set the user name for basic authorization, use the '''-Headers''' parameter:


<code>-Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))}</code>
<code>-Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))}</code>


<code>((Invoke-RestMethod -Uri 'https://allegro-mm-XXXX/API/stats/modules/ip/ips_paged?sort=bytes&reverse=true&page=0&count=10&timespan=60&values=50' -Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))} -ContentType'application/json; charset=utf-8' -Method 'Get' -SkipCertificateCheck). displayedItems[0]).ip</code>
You also need to announce that you accept JSON as response with:


<code>Invoke-RestMethod -SkipCertificateCheck ...</code>
<code>-ContentType'application/json; charset=utf-8'</code>
 
To disable the certificate check, use:
 
<code>-SkipCertificateCheck</code>
 
The URL must be passed with the parameter '''-URI''', so the full command is:
 
<code>Invoke-RestMethod -Uri 'https://allegro-mm-XXXX/...' -Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))} -ContentType'application/json; charset=utf-8' -Method 'Get' -SkipCertificateCheck</code>


== Examples ==
== Examples ==
404

edits