Automation & JSON Tricks
REST methods, JSON reading, controller concepts, and automation-tool distinctions.
REST methods
Read JSON
Objects use curly braces and key/value pairs.
Arrays use square brackets and ordered values.
Strings require quotes; numbers and booleans do not.
Trace nesting one level at a time before selecting a value.
Tool distinctions
Why the REST methods differ
GET should retrieve a representation without changing the resource.
POST commonly creates a subordinate resource or invokes an action where the server chooses the resulting identity.
PUT usually replaces the addressed resource; PATCH changes selected fields.
DELETE requests removal. Authentication, authorization, headers, URI, and response code still determine whether a request succeeds.
Read an API response
Real scenarios you'll actually face
"The automation script that's run fine for months suddenly started failing overnight." Check the status code first, before touching the code: 401 means the credential/token itself stopped being valid (a common cause — a token with an expiration date that finally hit it), 403 means the credential is fine but no longer has permission for that specific action (someone tightened an access policy), and 400 means the payload itself is malformed — three completely different fixes hiding behind the same symptom of "it stopped working." Reading response bodies, not just the status code, usually tells you which one in plain language.
"The API call keeps returning 400 and I can't see what's wrong with the JSON." The two most common, most avoidable JSON mistakes: a trailing comma after the last item in an object or array, and single quotes instead of double quotes around strings — both are invisible at a glance and both make an entire payload unparseable, not just the one field near the mistake. Validate the JSON on its own (a linter, or even just pasting it into a formatter) before assuming the problem is in your code's logic — most "my script is broken" moments here are actually "my JSON is malformed" moments.
"I meant to update one field on a device through the API, and it wiped out settings I never touched." This is what happens when a PUT is used for what was actually meant to be a partial update — PUT replaces the ENTIRE resource with exactly what you sent, so any field you didn't include gets reset to its default, not left alone. PATCH is the method that only touches the specific fields you specify — the distinction between the two isn't academic, it's the difference between a clean automated change and an outage you have to explain.
Want a printable copy?
This complete guide is also available as a professionally formatted PDF.
Download PDF ↓