During this project you sometimes (often!!) hit a brick wall (or roadblock, whatever you want to call it).  You play around for an hour and don’t get anywhere, in fact you normally go backwards and break another piece of code and have to revert the whole thing back to the start.  Usually the problem is resolved by asking for help from a senior dev.  You really want to solve the problem yourself, but you just can’t it’s really frustrating.

Today I hit such a roadblock.

I am working on the section of the admin portal that allows a staff member to place a rental booking.  I have diligently put together all the parts of the HTML form and data-bound them to properties of the object that is required by the API.  Finally the code seemed ready and hit the submit button to send my completed object off to the web API…….

Obviously it didn’t work, it never does –  the API just kept throwing back a server 500 error.  At first I thought it was something to do with date formats, due to some messages in the debugger, however this quickly proved to be a false lead.  Next up I thought maybe I had a malformed JSON object.  Luckily I have the customer booking portal to compare my results to.  The customer booking portal hits the same API as the admin booking page, the customer booking portal was still working.  I spent an hour making adjustments to that my admin page was sending EXACTLY the same JSON object as the customer portal, one worked, mine didn’t, dammit, really frustrating.

What else to check….. Luckily we have been using ‘Fiddler’, a neat piece of software that monitors HTTP traffic, it logs all calls to the APIs and so it is possible to compare what the customer portal was sending with what the backend sent.

Whilst the JSON objects were identical I noticed a slightly different HTTP header was attached to the request from the customer portal.  There was an additional header that informed the API that the payload contained a JSON object.

I delved deep into the customer portal code, found the little bit of magic that made this work and hey presto my admin portal was working just as it should.

The final step was to refactor this code out into the common API code (meaning that we won’t have to repeat ourselves everytime we use the Booking API) and the world was a good place again

I finished this about 10.30pm and after last weeks experience, I opted not to push it until the morning.

We have a demo on Friday, I hope to get a create/list/edit booking function complete by then, fingers crossed

I said this project has good days and bad days, today was a good day, wonder if I can make two in a row 🙂

tues 8-30 – 4 (172.5 hrs)

weds 8.30 – 5 (180.5 hrs)

thurs 8.30 – 6 (189.5 hrs)

fri 1.3 – 5 (193 hours)

Advertisements