0

I am working on integration PRTG with salesforce. PRTG is locally installed (at http://127.0.0.1 ). I used following endpoint

public String baseUrl = 'http://127.0.0.1/api/table.xml?content=sensors&columns=sensor&username=prtgadmin&passhash=xxxx'; /
         public String username = 'prtgadmin';  
         public String password = 'Pune@123'; 
         public void PRTGIntegration1(){   
          HttpRequest req = new HttpRequest();
          Http http = new Http();

        // req.setHeader('Accept', 'application/xml');
      //  req.setHeader('Content-Type','application/xml');
        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(Ieq);  
    String ResponseJsonString = res.getStatus();    
}

But i am getting status code as 403 forbidden after execution.

is there any problem with url i am mentioning because prtg is on LAN. So when i call endpoint from cloud do i have to mention ip address or something else i should take care of

Please help!!

  • You need to pass the global Address which can be accessed from browser as well. Local address won't work. – Tushar Sharma Dec 19 '18 at 11:16
  • what do you mean by global address.. external IP? – Ujwala Mane Dec 19 '18 at 12:27
3

http://127.0.0.1/ or http://localhost is hosted in your local machine. Its not a publicly available unique address that anyone can access outside your local network.

You have 2 Options here.

  1. Host your app on a publicly accessible server like AWS or Heroku
  2. Create a Proxy tunnel that will provide a public URL which will hit your local machine's running instance.
0

As explained by Pranay in #2 there is a utility called ngrok which helps you to securely expose your local web server to internet. Salesforce requires that all endpoints use HTTPS so ngrok will be helpful. You install ngrok and point it to port 8080 so that you can call it from Salesforce.

Please note: - I am not an employee of ngrok or promoting it anyway.

  • i used ngrok to create proxy tunnel.. but it is giving me error as tunnel xxx not found..? Can you help me in this regards? – Ujwala Mane Dec 21 '18 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.