But why should I care about this stuff? Isn’t it enough to write good code and assume released APIs work as expected?
Hi all,
I want to share a couple of tips-and-tricks up my sleave to help you debug your API calls when you’re testing out your applications.
Frequently, you’ll run into needing to test API endpoints – typically /GET or /POST calls – for a customer-facing transactional application, for sending or retrieving data from an Enterprise data tier, or for triggering an event/action to an existing system. You’ll typically leverage open-source software or licensed-products such as ThunderClient ( VSCode ), Postman, or Insomnia to create small configurations to test API calls.
A Street-Fighting Checklist of Good Tips-and-Tricks – the Concise Version
- Check VPN Connectivity
- Check Environment configurations
- Inspect SSL/Certificate Issues
- Enable/disable SSL verification
- Check API call layers
- Check certificates, CA Certificates, and certificate paths
- Headers check
- Check the parameter string / query correctness
- Install and update latest certificate libraries
- Install and update the latest langauge SDKs and libraries
- Leverage sandbox/isolated environments/containers ( Docker )
- Introduce isolation levels
- Verify payload correctness and comprehensiveness
- Check security information
- Set the correct method type
- Passwords and Accounts Check
- Compare to other calls
- Sync with other developers : brainstorm and get ideas
- Check certificate environment variables
- Leverage CoPilot/AI textual tools
- Generate code from Testing Clients ( e.g. Postman )
A Street-Fighting Checklist of Good Tips-and-Tricks – with explanations
- Check VPN Connectivity
- Check Environment configurations – e.g. passwords ( DB_PASSWORD ) or tokens values. Check the value is correct for the environment and that the environment is correct ( e.g. DEV, QA, PROD )
- Introduce isolation levels
- Network isolation – test if the issues persist when VPN connectivity is on versus off. Test
- Client-side versus server-side isolation – if there’s an issue, ask if another developer can execute the same API calls from their machine. If they can execute the call, the issue is server-side – otherwise, there’s still the possibility of client-side issues.
- Verify payload correctness and comprehensiveness
- Oftentimes, payloads can be mal-formatted – key:value pairs are incorrect or not comprehensive enough. Check that payloads are fully correct.
- Check security information
- For AuthN, AuthZ, and other security reasons, API calls usually involve a subset of headers or BEARER tokens. Verify correctness
- Inspect SSL/Certificate Issues
- Issues could be due to the SSL ( Security Sockets Layer ) protocol, used for network encryption. Sometimes, you’ll be able to disable SSL and have request flowing. But other times, you’ll need to update client-side or server-side certificates ( or even CAs : Certificate Authorities ).
- Enable/disable SSL verification – setting this parameter to FALSE can enable us to bypass client-side certificate checks or server-side certificate checks. It’s not recommended ( we loose encryption in-transit ).
- Adding certificates to library paths – you may need to append server-side certificates on the library path your client-side applications recognize. This may entail appends to your cacert.pem files ( or others ). Can we experiment around and manually specify paths such as certificate_path or ca_certificate_path? Leverage libraries like Python’s certifi.where() method to view where your virtual env/runtime loads certificates.
- Underlying Queries – are your queries correct? API calls include queries – either in their parameter string ( following the ? symbol ) or in request body payloads. The call itself can be correct, but the query executed can be incorrect, and you might be misinterpreting a 4xx error incorrectly.
- Experiment with isolated environments – if applications don’t run locally, can we run in a more isolated environment? A container can be a good example, where we can set up a barebones minimal configuration. This isolates and helps us detect if misconfigurations arose up on local machines
- Check your language’s SDKs and Libraries – maybe you need to upgrade or change the name of a web methods library ( e.g. requests for Python ). See commands like
python3 -m pip install <latest_library> - Check API call layers – e.g. say you’re working with a REST client to contact another part of an Enterprise, but before doing so, you first need to connect to said Enterprise. Can we diagnose the underlying connection ( the layers below )? Issues can be upstream versus downstream.
- Set the correct method – you’d be surprised how often a dev struggles with an API call because they’re executing a /GET that should be a /POST, or even a /POST that should be a /PUT. This happened with me on an attempt to execute /GET calls to GraphQL which should have actually been a /POST call.
- Headers check – There’s a good number of headers – Authorization, Contnet-type, Accept, Content-Encoding, Keep-Alive, Accept-Language – passed on API calls. Make sure they are correct ( even ask if they’re needed – a lot of headers are superfluous and can be deleted ).
- Passwords and Accounts Check – passwords are frequently rotated ( typically on a 90-day period ) within organizations.
- Compare to other calls – if your current call doesn’t work, test two other calls whose structures share similarity. Like a puzzle, making equivalent changes until your call starts working ( or still doesn’t ). We can build off of what already works, from client-side.
- Certificate environment variables – explicitly set the paths to certificates in your code ( or your local environment ).
- Sync with other engineers – every engineer brings their different domain knowledge and ways of looking at problems. You might not see what another engineer sees, and vice versa.
- Leverage Co-Pilot/AI Tools – we can provide code context on what an issue can be and get (nearRT) feedback within 1-2 minutes of what’s going on. On each iteration, add more debug and logging output – provide more context and help the AI tool output more accurate results.
- Client-code generation – manual-developed calls have a high success rate from Postman or Thunderclient. What if we can use their auto-gen coding capabilities to write up quick unit tests?
More Best Practices
- Folder structures – introduce a folder structure to API calls. Start organizing and grouping them. E.g. if you have API calls ( /GET and /POST ) for application one and for application two, introduce two folders with corresponding titles.
- Upload your collections – surprisingly, you’ll also run into the scenario where multiple developers on a team use the same set of configurations, so go ahead and create collections and then share them on a central location!!!
- Create environments – creating environments ( for DEV/QA/PROD ) and setting env-specific configurations ( e.g. passwords of hostnames ) is useful for quick testing. We can avoid creating duplicate API call tests if we leverage global configs.

Leave a comment