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://helpdesk.paessler.com/en/support/solutions/articles/61295-problem-with-the-prtg-api but no solution was found.
Article Comments
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")
Jan, 2019 - Permalink
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?
Feb, 2019 - Permalink
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).
Feb, 2019 - Permalink
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
Jan, 2019 - Permalink