That highlighted piece of code, “json.dumps”— that, or the absence of it, haunted me badly for two and a half days!
So, I'm working on something now. It's called an API client. For those not in the know, it's a program that sends data to a server, waits for that server to process it, then catches the data the the server returns for further processing. In this case, my program has to send some shipment information to a server in the UK so that that UK server can create a shipment record, and then return some information like a shipment ID. That information is then to be used to create a sticker label that our customers are to stick onto their packages so that they arrive at their designated places.
For the life of me, I forgot to include that piece of code “json.dumps” in the part of my program that sends the data to the UK server.
My client and I had to enlist the help of the service provider's support people for help. It didn't help. For the last couple of days, we were focused on how the data was structured— what values went into which variables. We came to the point that the test JSONs I provided for support to evaluate was, to borrow from the XML spec, well-formed and valid. And we didn't know what to do any more and basically gave up on each other.
I hate these kinds of situations, being helpless and all.
In desperation, I posted a call for help on the developer message board at the office. Thirty seconds later, Clarence came over and simply asked whether I was actually sending in JSON and not a Python dictionary. Fuck my life, as they say. But all is well now. I've created my first shipment record with that supplier and I'm moving forward with the development of the API client. Before the end of the day, I hope I can finally draw this thing to a close. (Good luck with that. So, so sleepy!)
I lost a lot of sleep over this— don't mention that we had to deploy something that concerns another supplier this morning. It won't happen again.
Lessons learned: sometimes, we focus on solving the wrong problems and when we do, nothing gets solved; sometimes, a fresh pair of eyes is all that is necessary to correctly identify a problem and offer a working solution; it always pays to seek help— and not wait until you're utterly desperate.