Hello, I am creating a REST sensor using POST method to query the server. The POST request (json format) contains some essential information which I'd like to hide from the PRTG end user who will be using the sensor. For example, postdata field: { "HEAD": { "ID": "XXXXXl", "TIMESTAMP": "XXXXX", "TRANS_ID": "XXXXXXXXXXX", "TOKEN": "XXXXXXXXXX" }, "BODY": { "terminals": [ "XXXXXX" ] } }

Is there a way to send the postdata as a json file/object rather than an open text data?


Article Comments

Hello there
Thanks for reaching us
Unfortunately, such action cannot be possible on the sensor configuration settings
I'm afraid it is not supported


Apr, 2023 - Permalink

Update. In case this may help others, the objective was achieved by using the Powershell script (.ps1 in the Custom sensor/ EXE folder) and EXE/XML sensor.

The contents of the script: ####### param([string]$terminalID) $body = @" { "HEAD": { "ID": "Id", "TOKEN": "asdlknv98)mn88888a94e6ff72468b" }, "BODY": { "terminalIds": [ "$terminalID" ] } } "@ $url = 'https://some/url/api/terminal/state/list/v1' [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" $headers = @{ 'Content-Type' = 'application/json; charset=UTF-8' 'Accept' = 'application/json' 'Accept-Encoding' = 'gzip' } $rawresult = Invoke-RestMethod -Uri $url -Method 'Post' -Body $body -Headers $headers -ContentType "application/json" $result1 = [int]$rawresult.rows.currentState $result = @" { "prtg": { "result": [ { "channel": "Status" , "value": $result1, "unit": "Custom" } ] } } "@ $result ######## The result prints out as a channel in the sensor Settings


Apr, 2023 - Permalink