Hi,

Im trying to get the parent tag of a device using the api in a powershell script. PRTG is at the newest update and you wont get a parent tag until you got on the Web UI on the device Settings and just click a few times around. Could it be that it is a bug or am i just doing something wrong?

This one works but only if you visited the Device on the WebUI Invoke-WebRequest -Uri "https:// **prtg** /api/getobjectproperty.htm?id= **deviceid** &name=parenttags&username=prtgadmin&passhash= **passwordhash**"

Thank you


Article Comments

Hi Marco,

Username and passhash are correct? What result do you get from Invoke-Webrequest?


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2017 - Permalink

Hi,

Yes im sure that those are correct since there is a reply getting to me.

Before visiting UI

PS C:\Powershell> Invoke-WebRequest -Uri "https:// prtg /api/getobjectproperty.htm?id=3843&name=parenttags&username=prtgadmin&passhash= "


StatusCode        : 200
StatusDescription : OK
Content           : <?xml version="1.0" encoding="UTF-8" ?>
                    <prtg>
                    <version>17.3.32.2478+</version>
                    <result></result>
                    </prtg>
RawContent        : HTTP/1.1 200 OK
                    Connection: close
                    X-Content-Type-Options: nosniff
                    X-XSS-Protection: 1; mode=block
                    Content-Length: 105
                    Cache-Control: no-cache
                    Content-Type: text/html; charset=UTF-8
                    Date: Wed, 3...
Forms             : {}
Headers           : {[Connection, close], [X-Content-Type-Options, nosniff], [X-XSS-Protection, 1; mode=block], [Content-Length, 105]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : System.__ComObject
RawContentLength  : 105

After visiting Web Interface --> this host

PS C:\Powershell> Invoke-WebRequest -Uri "https:// prtg /api/getobjectproperty.htm?id=3843&name=parenttags&username=prtgadmin&passhash="


StatusCode        : 200
StatusDescription : OK
Content           : <?xml version="1.0" encoding="UTF-8" ?>
                    <prtg>
                    <version>17.3.32.2478+</version>
                    <result>Linux_SMS</result>
                    </prtg>
RawContent        : HTTP/1.1 200 OK
                    Connection: close
                    X-Content-Type-Options: nosniff
                    X-XSS-Protection: 1; mode=block
                    Content-Length: 114
                    Cache-Control: no-cache
                    Content-Type: text/html; charset=UTF-8
                    Date: Wed, 3...
Forms             : {}
Headers           : {[Connection, close], [X-Content-Type-Options, nosniff], [X-XSS-Protection, 1; mode=block], [Content-Length, 114]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : System.__ComObject
RawContentLength  : 114




PS C:\Powershell> 

It's quite a problem for me since i want to get the tag wheter i visited this host recently or not.

Thank you


Aug, 2017 - Permalink

Hi Marco,

Bug confirmed. I'll create an issue and link this thread to it. I'll let you know once it's fixed.
Would opening the device settings page via Invoke-Webrequest as an intermediate step work for you?
Because this will not be on high priority from what I can tell due to the low usage rate...


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2017 - Permalink