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



23 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,194) 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,194) 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,194) 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,194) 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,194) 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]



Votes:

0

Your Vote:

Up

Down

I am having same issue, I was using Postman and curl to see what different results I could get. My query is to get a list of all the host that are in the database. Using curl: curl -k -o C:\Users\smiles\Desktop\prtghost.xml "http://"myprtgserver"/api/table.xml?content=devices&output=csvtable&columns=device,host?username="xxxx"&passhash="xxx" " myprtgserver is an IP address and username and password I have verified

with postman I just select GET and enter the url string both give me the "unauthorized" tag on it.

<?xml version="1.0"?>
-<HTML>
-<BODY>
<B>Unauthorized</B>
</BODY>
</HTML>

Not sure what I am missing.

Created on Feb 11, 2020 7:30:45 PM by  smiles (0)

Last change on Feb 12, 2020 12:32:36 PM by  Moritz Heller [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi smiles,

did you already tried the simple command:

curl "http://"myprtgserver"/api/table.xml?content=devices&output=csvtable&columns=device,host?username=xxxx&passhash=xxx

In addition, please use no double-quotes in username and passhash

Created on Feb 12, 2020 12:34:27 PM by  Moritz Heller [Paessler Support]



Votes:

0

Your Vote:

Up

Down

My output comes out to:

curl: (6) Could not resolve host: https

Which this is a new result from before.

Created on Feb 12, 2020 1:54:35 PM by  smiles (0)



Votes:

0

Your Vote:

Up

Down

I found a mistake. Sorry about that.

I used the url you gave me....

curl "http://"myprtgserver"/api/table.xml?content=devices&output=csvtable&columns=device,host?username=xxxx&passhash=xxx

and it gives me:

<HTML><BODY><B>Unauthorized</B></BODY></HTML>

Created on Feb 12, 2020 1:59:25 PM by  smiles (0)



Votes:

0

Your Vote:

Up

Down

Hi smiles,

Thank you for the feedback.

This is only a dummy link. You need to replace "myprtgserver" with your Core Server URL and then replace the username and passhash according to the used credentials.

Created on Feb 12, 2020 3:41:41 PM by  Moritz Heller [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I am aware of that.....I replaced it with my server and the username / hash with the correct information. The above result was still the result

Created on Feb 12, 2020 3:53:44 PM by  smiles (0)



Votes:

0

Your Vote:

Up

Down

Hi smiles,

Thank you for the feedback.

Did you already tested the API call in an inkognito tab of your browser? In addition, I noticed that you have a "?" after "host". Please note that a "?" displays the start of parameters. However in this URL the parameters already started and therefore you would need to replace the "?" with a "&".

Created on Feb 13, 2020 10:56:10 AM by  Moritz Heller [Paessler Support]



Votes:

0

Your Vote:

Up

Down

When I replace the ? with the &:

http://10.x.x.x/api/table.xml?content=devices&output=csvtable&columns=device,host&username=xxxx&passhashxxx

I get:

<HTML>

<BODY><B>Unauthorized</B></BODY>

</HTML>

When I paste the URL into the incognito browser, I get:

Unauthorized

Created on Feb 17, 2020 12:35:59 PM by  smiles (0)



Votes:

0

Your Vote:

Up

Down

Hi Smiles,

I noticed that you forgot a "=" after passhash. Did you used the same URL while testing? You can also create a API query via our "XML Table Query Builder" which is under "Setup > PRTG API > Live Data".

Created on Feb 17, 2020 7:32:18 PM by  Moritz Heller [Paessler Support]



Votes:

0

Your Vote:

Up

Down

The problem wasn't the string. It was the SSL certification check. If you turn that off or switch to turn this off, then the string as it was originally worked.

I did add the = at the end before the password.

Created on Feb 18, 2020 7:48:37 PM by  smiles (0)



Votes:

0

Your Vote:

Up

Down

Hi smiles,

Thank you for the feedback. Glad to hear that the API call works now!

Created on Feb 19, 2020 11:21:17 AM by  Moritz Heller [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.