Thursday, September 22, 2016

Getting a 500 Error When Trying to Access a REST API from C#?

This just might be the solution.

Here's the deal...  I need to write a simple C# client to access data from a REST API served up by an Apache Tomcat server.  Not a big deal at all...  should be pretty simple...

Should be...

For some unknown reason, my attempts generated nothing but '500' errors from the server.  Myself and our resident network wizard captured my traffic and we compared the headers of a successful GET using CURL and the non-successful attempt using my simple C# program.

After trying a few things with no success, I noticed the CURL capture showed an 'Accept: */*' header.  My C# program did not.  So, I added this...

request.Accept = "*/*";

SHAZAM!!!  No more 500 errors.

No search results from Google helped.  None mentioned this as being a possibility.  But, heck...  it worked.

By the way, this Apache server is what I like to call LegalWalled.  Yes, it's our server but if we touch it, or even log onto it using SSH without the guidance and approval of the vendor's support group, we could violate our support contract...  so opportunity to dig into why that specific error was generated.

Monday, September 12, 2016

Yes... I did that... Don't remember it, but did it...

I am a programmer (or is that obvious?).  Once in a while I will be tasked with researching or changing a program that I originally wrote.  I get the most recent code from our Source Repository System and start reviewing the code.  There is no doubt the program came from my brain, but it is certainly not familiar.  Why did I put these functions into a DLL?  What was I thinking when I designed this junk table?  OMG, WHY did I use singe letter variables???  WHY?!?!?!?!?

Maybe this happens with people in other professions...  read this to mean I hope sincerely that any doctor, dentist, commercial pilot or member of law enforcement who feel a similar temporary disorientation should firmly consider taking the day off!

Does a mechanic one day, look at a half-rebuilt carburetor that they have been working on for a month and wonder what motorcycle it came from?  Does a blackjack dealer in Vegas pause and wonder what those cards with an "A" printed on them mean?  Does a baseball umpire call "STRIKE!" before the pitcher throws the balll?

Anyway...  Walter Bishop from Fringe may never have said this, but maybe he could have...