28
edits
(→Using API token: add example with a header file) |
(→PowerShell: remove bogus '-ContentType' description (ContentType specifies the request content type, not the accepted response content type)) |
||
Line 58: | Line 58: | ||
<pre>-Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))}</pre> | <pre>-Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))}</pre> | ||
When sending POST requests (or other requests with a body), the request content type must be specified (not necessary for requests with empty request body (GET, DELETE)): | |||
<pre>-ContentType'application/json | <pre>-ContentType'application/json'</pre> | ||
To disable the certificate check, use: | To disable the certificate check, use: | ||
Line 68: | Line 68: | ||
The URL must be passed with the parameter '''-Uri''', so the full command is: | The URL must be passed with the parameter '''-Uri''', so the full command is: | ||
<pre>Invoke-RestMethod -Uri 'https://allegro-mm-XXXX/...' -Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))} | <pre>Invoke-RestMethod -Uri 'https://allegro-mm-XXXX/...' -Headers @{Authorization = ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'USER', 'PASSWORD'))))} -Method 'Get' -SkipCertificateCheck</pre> | ||
==== Using API token ==== | ==== Using API token ==== | ||
When using an API token, the Authorization header changes (with '''API_TOKEN''' as a placeholder for the real token): | When using an API token, the Authorization header changes (with '''API_TOKEN''' as a placeholder for the real token): | ||
Invoke-RestMethod -Uri '<nowiki>https://allegro-mm-XXXX/...'</nowiki> -Headers @{Authorization = ("Bearer API_TOKEN")} | Invoke-RestMethod -Uri '<nowiki>https://allegro-mm-XXXX/...'</nowiki> -Headers @{Authorization = ("Bearer API_TOKEN")} -Method 'Get' -SkipCertificateCheck | ||
=== jq === | === jq === |
edits