What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Rest Sensor postdata formatting

Votes:

0

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?

json post prtg restapi

Created on Apr 17, 2023 2:31:02 AM

Last change on Apr 25, 2023 8:10:32 PM by  Luis Quesada (Paessler Technical Support)



2 Replies

Votes:

0

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

Created on Apr 25, 2023 8:10:06 PM by  Luis Quesada (Paessler Technical Support)

Last change on Apr 25, 2023 8:10:40 PM by  Luis Quesada (Paessler Technical Support)



Votes:

0

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

Created on Apr 26, 2023 5:13:50 AM

Last change on Apr 27, 2023 6:48:36 AM by  Felix Wiesneth [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.