Can't Debug Web API called from MS Access

3

I have a Web API (.Net MVC) that's being called from an MS Access VBA Module, like so:

objHTTP.Open "POST", "http://ourwebserver/api/run", False
objHTTP.setRequestHeader "Content-Type", "application/json"
objHTTP.send (body) 'body is a string containing the parameters to be used
Debug.Print objHTTP.Status
Debug.Print objHTTP.responseText

Well, I need to be able to debug the actual api. So, I have the project all loaded on my local machine, but I'm not sure how to actually debug the code.

What I've tried so far is to run the project, set a breakpoint at the top of the controller, then change the objHTTP.Open command to point to the localhost entry that's created:

objHTTP.Open "POST", "http://localhost:54321/api/run", False

as well as:

objHTTP.Open "POST", "http://localhost:54321/", False

...but, in both cases, the breakpoint is never hit. It fails with Status = 500.

I've also tried attaching to debugger... but I don't know what to attach it to. There's no w3wp.exe in the list. I've tried to attach it to MSACCESS.exe and Chrome, but I'm just having no success. When I attach to MSACCESS.exe, I get an error about not being able to establish a connection.

So essentially, I'm trying to figure out how to tell my VBA process to call my local API code so's I can debug it. I'm having a hard time figuring out the magic words to make this happen.

Edit: For the record, when I try to run the project (F5 from VS), I get the following RTE in my browser:

Could not load file or assembly 'Antlr3.Runtime' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))

asp.net-mvc
ms-access
asp.net-web-api
asked on Stack Overflow Aug 1, 2016 by Christine • edited Aug 1, 2016 by Christine

1 Answer

2

Figgered it out! I had run this solution before on my local machine, but had forgotten the sorcery required to get it to work. Basically, this error:

Could not load file or assembly 'Antlr3.Runtime' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))

...was the result of Identity Impersonate being true in my web.config file. So, we do this:

<identity impersonate="false" userName="dom\UserName" password="#########"/>

Then, I was able to F5 into my web app with no errors, and call the API with this code in VBA:

objHTTP.Open "POST", "http://localhost:54321/api/run", False

I can now call the API from Access, hit breakpoints and step through!

answered on Stack Overflow Aug 1, 2016 by Christine

User contributions licensed under CC BY-SA 3.0