New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Why do I get unauthorized when calling the API?

Votes:

0

Your Vote:

Up

Down

I'm using cURL to do an api call but receive <HTML><BODY><B>Unauthorized</B></BODY></HTML> as a return. I've tried both password and passhash in the url but both get the same results. If I use the exact same url in my browser I get the xml output fine.

get http prtg unauthorized xml

Created on Jan 29, 2014 11:01:24 PM by  mdewart (0) 2



12 Replies

Votes:

0

Your Vote:

Up

Down

Could you please post the URL in case? You could also forward us the same to [email protected] In the latter case, please refer to this thread in your mail.

Created on Jan 30, 2014 12:43:27 PM by  Patrick Hutter [Paessler Support] (7,164) 3 3



Votes:

0

Your Vote:

Up

Down

The URL I'm using is https://"myserver:port"/api/table.xml?content=sensortree&username="myusername"&passhash="myhash" Of course everything in quotes has been replaced. I tried other content such as content=sensors&columns=sensors but they gave the same result.

Created on Jan 30, 2014 1:21:18 PM by  mdewart (0) 2



Votes:

0

Your Vote:

Up

Down

In this case it could really only be a wrong username or passhash. Just on the off chance, does it work with "?login=xxx&passhash=xxx'?

Created on Jan 30, 2014 2:01:31 PM by  Patrick Hutter [Paessler Support] (7,164) 3 3



Votes:

0

Your Vote:

Up

Down

It does not, I also tried name instead of username because I saw an example using that somewhere.

Created on Jan 30, 2014 2:03:42 PM by  mdewart (0) 2



Votes:

0

Your Vote:

Up

Down

I just tried with http://mysevrver/api/table.xml?content=sensortree&username=xxx&passhash=xxx and it worked just fine. Could this have to do with your username? Do you have any special characters or similar in the same?

Created on Jan 30, 2014 2:38:12 PM by  Patrick Hutter [Paessler Support] (7,164) 3 3



Votes:

0

Your Vote:

Up

Down

No special characters in the username or server address, there is an @ symbol in the password, but obviously not the hash. Are you doing this with cURL?

Created on Jan 30, 2014 2:41:56 PM by  mdewart (0) 2

Last change on Jan 30, 2014 7:37:37 PM by  Patrick Hutter [Paessler Support] (7,164) 3 3



Votes:

0

Your Vote:

Up

Down

Could it be that cookies for a valid PRTG session still exist in the browser? If so, you wouldn't notice that it is logging in wrongly, seeing as you would receive the data of said session.

Created on Feb 3, 2014 12:13:52 PM by  Patrick Hutter [Paessler Support] (7,164) 3 3



Votes:

0

Your Vote:

Up

Down

No, cURL is a command-line based browser. I managed to get it working though. The proper method with cURL is to put the entire URL in quotes so that it doesn't try to extract the parameters and pass them seperately. Here is my working example: curl -k -o /home/username/PRTG/test.xml "https://server:port/api/table.xml?content=messages&output=csvtable&columns=objid,datetime,parent,type,name,status,message&username=myuser&password=mypass"

Created on Feb 3, 2014 1:05:31 PM by  mdewart (0) 2



Votes:

0

Your Vote:

Up

Down

Sorry for bringing this post back to the graveyard, but I have the same case. Exactly the same "Unauthorized" response also using cURL. I tried to work around using "user agents" to simulate conventional browsers like Chrome and Firefox but resultless. But when I use the same url in a conventional browser I works fine.

Can anyone help me?

Created on Aug 19, 2015 9:09:23 PM by  vtexog (0)



Votes:

0

Your Vote:

Up

Down

What URL are you using? Strip the actual passhash and username and I'll have a look.

Created on Aug 20, 2015 7:57:58 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi! Patrick, I'm also facing the same problem. can't seems to get the cURL working on my Ubuntu terminal or script.

My Curl

curl http://172.16.17.5:8080/api/getobjectstatuscustom.htm?id=2218&name=lastvalue&show=text&content=lastvalue&username=xxxxx&passhash=yyyyy
}}}}

This is the response from the curl command at Ubuntu
{{{
<HTML><BODY><B>Unauthorized</B></BODY></HTML> 

However the same URL works perfectly on my browser The result I got at my browser was the temperature of my UPS

33 °C

Below is the actual page view source

<?xml version="1.0" encoding="UTF-8" ?>
<prtg>
<result>33 °C</result>
</prtg>

May I know how can I resolve this problem?

Created on Jul 8, 2017 1:17:47 PM by  Ivan (0)

Last change on Jul 10, 2017 4:59:25 AM by  Luciano Lingnau [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Ivan,

Please put the URL in the command in double-quotes:

curl "http://172.16.17.5:8080/api/getobjectstatuscustom.htm?id=2218&name=lastvalue&show=text&content=lastvalue&username=xxxxx&passhash=yyyyy"

Does that work better?

Best regards.

Created on Jul 10, 2017 1:00:46 PM by  Dariusz Gorka [Paessler Support]



Please log in or register to enter your reply.


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.