by Jaime Rosales (@afrojme)
For quite sometime I've been playing with cURL and the Forge Platform, and to start this 2017 I will be posting about my research using cURL and JQ processor together with the Forge Platform.
Using Terminal I found a quicker and simpler way for myself to use different workflows when using the Authentication API, such actions as obtaining 2 legged & 3 legged access tokens. With the Data Management API, I've been able to create, upload, request translation, access to Hubs and add new files to specific projects that I'm part of. Everything from the Terminal using cURL. But I know what you can be thinking "cURL from terminal, is so unorganized, so hard to read, so easy to mess up." I could not agree more with some of these thoughts. When your response has more than 1 line of JSON data returned, I agree it can be messy and hard to read.
I know others have decided to use REST Apps such as Paw or Postman, since the fear of messing up one character in your cURL can give you problems and at the same time, you get a better organized JSON result. But bare with me, I found out about JQ while using cURL and since then It has made quite a difference when testing the api's.
What is JQ? jq is a lightweight and flexible command-line JSON processor. A jq program is a “filter”: it takes an input, and produces an output. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks. It lets you visualize the JSON response in a organized way and it becomes easier to read when using terminal. How to use it? It requires a basic installation, JQ can be download for different OS platforms from here. After installation has been performed you should restart your Terminal and you would be ready for testing. You can check your version of JQ by simply typing "jq --version" in your terminal, which will assure you JQ was successfully installed.
Let's look at how the previous cURL actions to obtain a 2 legged access token and create a bucket looks after using JQ from Terminal.
As we can see JQ structures and color codes the result JSON from our REST call using cURL. Later on I will be posting the entire workflow on how to start from obtaining a 2 legged access token up to translating a file and get back the URN ready to be displayed in the Viewer. Followed by a 3rd post on how to access my a360 hubs and add a file to my project or another project I'm part of, all using cURL and the JQ processor.
Thank you for reading.