WEEK 5: ENTRY 2
Having successfully deployed my Kurbenetes yesterday, today I started implementing the HTTPS GO Request Post. As my project will be using the Big Query API to query the data and post the result to my server, I was needed to make that client-server post request. Unlike the GET HTTPS Request, the POST request function accepts three parameters. The Go inbuilt Post function accepts these three parameters: The URL address of the server, the content type of the body as a string, and the request body that is to be sent using the POST method of type. The documentation was pretty easy and simple to comprehend, so I had less problems implementing the POST functions. However, I had to restructure my code to meet my project goals. Unlike the documentation, I was not hard coding the data I needed to post to my server. Mine was a two-way procedure: I had to first write a query in the Swagger API, then pass that query as the request body in the Post Function. Then, that query will be posted to my server.
Even Though I had all the functions I needed, my coding was failing. And again, it was the same mistake I made with the GET Request Function: I failed to log the error so that the logs will identify what part of my codebase the error is coming from. I must mention that Go has a very powerful Error Package called Logrus, which does a great job in logging errors. The syntax is very simple, since the post function body requires two variable declarations: response body and error, I just had to make an if conditional saying if the error is not nil, then log the error. By the way, the response body is what is posted to my server. This way, I was able to see the error that was making the code fail. It was a 403 error, which is an authorization failure. It turns out that not every employee has permission to query to have access to the firm’s Cloud Database like the Big Query. Therefore, I had to wait to be granted permission from the manager's manager because he is the project owner.
Overall, today was a combination of realizing how important it is to learn from previous mistakes and the appreciation of where I am now on my project. I felt bad when I fail to log the error, so I intend to reduce this type of hindrance because they shouldn’t be recurring. So too, I am more confident to say what i am doing unlike the previous weeks’ sessions. This could be because I am now understanding my project and developing a relentless attitude.
Comments
Post a Comment