Additional headers can be added to the -Headers
property as hash table entries:
$result = curl -Uri $uri -ContentType application/json -Method Get -Headers @{'X-AUTH-TOKEN'='09f4a92e8fbfc9f9f530771ac32d37a1'}
You may want to try converting your uri string to type [System.URI]
. This handles standard character replacement like ' ' to %20
. I think curl
does this already, but it may help you see if something is invalid:
$uri = [System.Uri]::new('http://127.0.0.1/centreon/api/beta/monitoring/services?search=\{"service.state":"2","service.is_acknowledged":"0"\}')
# check the output:
$uri.AbsoluteUri
http://127.0.0.1/centreon/api/beta/monitoring/services?search=%5C%7B%22service.state%22:%222%22,%22service.is_acknowledged%22:%220%22%5C%7D