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

duplicateobject not redirecting to URL of new object

Votes:

0

https://prtgserver/api/duplicateobject.htm?id=3812&name=Test&host=127.0.0.1&targetid=10294&username=admin&passhash=123456789 Duplicates the object but doesn't redirect to the URL of the new object. Instead it returns a login page.

I've tried with password and passhash.

This issue was reported at https://kb.paessler.com/en/topic/61295-problem-with-the-prtg-api but no solution was found.

api bug prtg

Created on Jan 29, 2019 2:26:47 AM



Best Answer

Accepted Answer

Votes:

2

If you inspect the URL of the login page it would redirect you to, you should find it actually contains the ID of the object that was created, e.g.

https://prtg.example.com/public/login.htm?loginurl=/object.htm?id=9999&errormsg=

In C#, you can see the value of this URL in your HttpResponseMessage's RequestMessage.RequestUri property.

Once you have the URL, you can extract the ID by decoding the response (in case there are any special characters that are encoded) and then doing a regex substitution

Regex.Replace(decodedResponse, "(.+id=)(\\d+)(&.*)?", "$2")

Created on Jan 29, 2019 12:04:39 PM



4 Replies

Votes:

0

Hello Alex,

The redirect after sending an API call is currently in consideration. Please bear with me that I cannot tell you if or when this is going to be addressed.


Kind regards,
Felix Saure, Tech Support Team

Created on Jan 29, 2019 11:47:28 AM by  Felix Saure [Paessler Support]



Accepted Answer

Votes:

2

If you inspect the URL of the login page it would redirect you to, you should find it actually contains the ID of the object that was created, e.g.

https://prtg.example.com/public/login.htm?loginurl=/object.htm?id=9999&errormsg=

In C#, you can see the value of this URL in your HttpResponseMessage's RequestMessage.RequestUri property.

Once you have the URL, you can extract the ID by decoding the response (in case there are any special characters that are encoded) and then doing a regex substitution

Regex.Replace(decodedResponse, "(.+id=)(\\d+)(&.*)?", "$2")

Created on Jan 29, 2019 12:04:39 PM



Votes:

0

Thanks LordMilko! Inspired by your suggestion, I was able to figure out what URL it was returning: /public/login.htm?loginurl=%2Fdevice.htm%3Fid%3D10372&errormsg= which isn't what the API says will return but at least I can now extract the id out of it.

Do you think that technically the HTML status returned should be a 3xx instead of 200?

Created on Feb 1, 2019 12:34:38 AM



Votes:

1

The API states it will respond with a "redirect to the URL of the new object". Regardless of the HTTP response code returned, technically speaking it has fulfilled its API contract. In my applications I only inspect PRTG's status codes to check for request failures (bad request, unauthorized, etc).

Created on Feb 1, 2019 7:46:14 AM




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.