0

I'm trying to make an Excel macro that can make a GET request to a Plumber API that is hosted on RConnect. I have developed the Plumber API, it works as intended. During testing, I ran it on my local machine, so it was running on 127.0.0.1:xxxx, and pasting this as the URL to be accessed in the VBA code worked fine. However, now that I've published the API to RConnect, using the URL for the API from RConnect no longer works from Excel, it just gives an error. Even when I click the URL while it's just typed into a blank cell in Excel, it gives me an error. But when I paste this exact same URL into Chrome, the response text that I expect is there, and it works fine.

The URL request code I was using prior to publishing to RConnect is

Dim objHTTP As Object 
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
objHTTP.Open "GET", URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHTTP.Send ("keyword=php")

My thinking is that it is some kind of issue with the CreateObject line, but I'm not sure. I don't have experience with web development, so much of this is foreign to me. Any help or input would be greatly appreciated. Thanks.

skippy_winks
  • 778
  • 3
  • 14
  • 31
  • 1
    What is the error message that you get? – Zac Oct 11 '19 at 14:17
  • @Zac I figured it out, it was an RConnect API permissions issue. The error I was getting was HTML, and in it, it said I may not have permission to access the URL. That tipped me off. Thanks. – skippy_winks Oct 11 '19 at 15:40

1 Answers1

0

I figured it out, the issue was the permissions that I had set for viewing the API on RConnect were set to be just me, but it has to be set to everyone.

skippy_winks
  • 778
  • 3
  • 14
  • 31