Hi, I am integrating prtg with salesforce. I installed localhost prtg. i am trying
"http://127.0.0.1/api/table.xml?content=sensors&columns=sensor&username=prtgadmin&password=xxxx"
and
"http://127.0.0.1//api/getsensordetails.xml?id=1002"
api on postman. this url is working on postman but not in class, it is giving me error as status code=403, forbidden . Not getting what is going wrong, do i have to mention somewhere in prtg about salesforce.

Please help..!!


Article Comments

Hi there,

The error 403 means that you are not authenticated and that you are not allowed to open that page. Please make sure that you either add:

username=USER&password=PASSWORD

or

username=USER&passhash=PASSHASH

To the URL so the call is authenticated. The first request should work, when the password is correct.

What do you get in a browser in a private tab?

Best regards.


Dec, 2018 - Permalink

i am using same combination of URL. i installed prtg in desktop with server as localhost. prtg is not getting opened in private browser it is opening in chrome. The same url is working in postman api app. it is giving me 200 response but when i call it from class it is giving 403 forbidden reply...


Dec, 2018 - Permalink

Hi there,

The question is what result do you get with the very same URL in a browser (when you are not logged in) in class?

If I understood you correctly, you use a different PRTG installation locally and in class, please check if the password or passhash maybe different between these installations.

Best regards.


Dec, 2018 - Permalink

when i put this url in browser and press enter .. it creates a xml file with proper response


Dec, 2018 - Permalink

Hi there,

Where exactly do you get the 403 error? Within a script?

Best regards.


Dec, 2018 - Permalink

following is my apex class..

public String baseUrl = 'https://127.0.0.1/api/table.xml?content=sensors&columns=sensor&username=prtgadmin&password=Pune@123'; // Base URL of your JIRA instance
public void PRTGIntegration1(){   
HttpRequest req = new HttpRequest();
Http http = new Http();
Blob headerValue = Blob.valueOf(username+':'+password);
req.setHeader('Authorization','Basic '+ EncodingUtil.base64Encode(headerValue));
req.setMethod('GET');
req.setEndpoint(baseUrl);
        
    try{
            //Execute web service call here      
    HTTPResponse res = http.send(req);  ///GETTING ERROR AFTER THIS CALLOUT
    String ResponseJsonString = res.getStatus();    
    system.debug('ResponseJsonString ======>'+ResponseJsonString );

Dec, 2018 - Permalink

Hi there,

Any reason you send a "Basic Authentication"-Header?

Also please try to use the passhash of that user instead to avoid issues with the special-chars in the password. You can get the passhash from under "Setup > Account Settings > My Account" by clicking the "Show Passhash"-button.

Best regards.


Dec, 2018 - Permalink

i passhash url.. still the same error status code.

do we have to put something in PRTG network monitor tool regarding who wants to communicate with PRTG.

do i have to mention salesforce url anywhere in PRTG or is there in connected app concept in PRTG


Dec, 2018 - Permalink

Hi there,

What do you get within PowerShell?

Invoke-WebRequest -uri "https://127.0.0.1/api/table.xml?content=sensors&columns=sensor&username=prtgadmin&password=Pune@123"

Also where do you execute this class? On the same server/computer where PRTG is installed on?

Best regards.


Dec, 2018 - Permalink

I havenot tried with powershell.

salesforce in cloud based.. so call will be going through cloud to PRTG installed in my machine


Dec, 2018 - Permalink

Hi there,

So you try to reach "https://127.0.0.1/api/table.xml...." from the Cloud? Correct? How should that work? You need to enter the correct IP-Address under what you can reach the PRTG Server externally. Otherwise Salesforce might not be able to connect.

Best regards.


Dec, 2018 - Permalink

thanks for suggestion i am looking integration with external IP. hi just a doubt, where to find server name of prtg i installed in my machine? why is 127.0.0.1 is appearing in url ? i searched for PRTG help video where there is no 127.0.0.1 in there url, some domain name is mentioned? how can i find domain name?


Dec, 2018 - Permalink

hi i am trying with external IP,

Just have doubt why is 127.0.0.1 is there in url. there can not be any domain name? I watched some prtg video where there is no 127.0.0.1 like address there are name like https://demoorg/wel...

How to find server name in PRTG?


Dec, 2018 - Permalink

Hi there,

The IP "127.0.0.1" translates to "localhost" and will only work on the Core Server itself. On any other device or server you won't reach the PRTG Webinterface via this URL. There you need to enter the correct IP address, FQDN or Hostname.

Best regards.


Dec, 2018 - Permalink