A working API request and a failing one can look nearly identical while differing in one important URL detail. Comparing them systematically helps you spot changes to the scheme, host, path, or query string—and avoid overlooking differences in parameter values, duplicates, and encoding.
Key Takeaways
- Compare the scheme, host, path, and query string separately before changing anything.
- Query parameter order, repeated keys, values, and encoding can affect how a request is interpreted.
- A URL comparison cannot reveal differences in headers, request bodies, authentication, or server-side behavior.
- Remove credentials and personal data before sharing URLs in tickets, logs, or bug reports.
Compare the URL in parts
Start with the exact URL for the known-good request and the exact URL for the failing request. Avoid reconstructing either from memory: copied browser addresses, client logs, and application code may show different stages of a request. If redirects are involved, distinguish the initial URL from the final destination.
For example, compare these two fictional requests:
Known good: https://api.example.test/v1/orders?limit=20&status=open
Failing: http://api.example.test/v1/order?limit=20&status=opens
Check each component:
| Component | Known good | Failing | What to investigate |
|---|---|---|---|
| Scheme | https | http | Whether the endpoint requires HTTPS, or whether a redirect changes the request. |
| Host | api.example.test | api.example.test | Whether the hostname, subdomain, or environment is different. |
| Path | /v1/orders | /v1/order | Whether the route, version, spelling, or trailing slash differs. |
| Query | limit=20&status=open | limit=20&status=opens | Whether a key or value is missing, misspelled, or unexpected. |
This example contains three changes. Do not assume which one caused the failure. Restore one component at a time, or build a request that differs from the known-good URL in only one way. That makes the result easier to interpret.
You can also use URL Diff to compare the two URL strings. Treat any visual diff as a way to find candidate differences, not as proof that the requests are otherwise equivalent.
Inspect query parameters closely
A query string begins after ?; parameters are commonly separated by &. Each parameter may have a key and value, such as limit=20. Small differences can matter:
- Different values:
status=openandstatus=opensare different strings. Check spelling, capitalization, whitespace, and whether a value is empty or omitted. - Missing versus empty:
?q=sends a parameter with an empty value;?sends an empty query string. An absent parameter, an empty parameter, and a parameter with the valuenullare not necessarily treated the same by an API. - Duplicate keys:
?tag=a&tag=bcontains twotagparameters. APIs and frameworks may interpret duplicates as a list, use the first value, use the last value, or handle them in another way. Check the endpoint's documented behavior rather than assuming duplicates are harmless. - Parameter order: Many endpoints treat
?a=1&b=2and?b=2&a=1equivalently, but this is not guaranteed. Request signing, caching, custom parsing, or server code may depend on the serialized query string or its order.
Encoding can also change what a server receives or how it interprets a value. For example, %20 is a percent-encoded space. In query strings parsed using form-style rules, + is commonly interpreted as a space, but raw URL handling and server implementations can differ. A literal plus sign may need to be encoded as %2B when it is intended as data. Encoded reserved characters can also have different effects from those characters used as URL separators. Check both the visible spelling and the endpoint's expected parameter format.
When a request includes a signature or a cache key derived from the URL, do not casually reorder parameters or re-encode values: even if two forms seem equivalent to a person, the system comparing the serialized strings may treat them differently.
Check what URL comparison cannot show
Two identical URLs can still produce different outcomes. A URL diff does not inspect:
- Headers, such as
Accept,Content-Type, or a custom API-version header. - The request body, including JSON fields and body encoding.
- Authentication and authorization, such as whether a credential is missing, expired, or lacks permission.
- Request method, such as
GETversusPOST. - Server-side behavior, including validation, deployment changes, rate limits, and application errors.
If the URLs match, compare these request details next. Capture the method, relevant headers, body, response status, and response body using an authorized client or application log. Redact sensitive values before saving or sharing a capture.
A practical debugging workflow
- Record both requests. Copy the known-good and failing URLs from the same kind of source, such as client logs or a request inspector. Note whether either request was redirected.
- Compare the four main parts. Check scheme, host, path, and query string. Also check whether a fragment appears in a copied URL: fragments are for client-side use and are not sent as part of an HTTP request.
- Inspect query details. Compare parameter names and values, missing or empty values, duplicate keys, order, and percent-encoding. Use the API's documentation to resolve ambiguous parameter behavior.
- Change one thing at a time. Start with the known-good request and alter only the suspected difference. Record the response for each attempt.
- If URLs match, compare the full request. Check the method, headers, body, authentication context, response, and server logs where available. A URL comparison cannot establish that these match.
- Redact before reporting. Remove or replace API keys, access tokens, session identifiers, personal data, and other sensitive values in both URLs and request captures.
When sharing a sanitized example, preserve the structure needed to explain the issue. For instance, replace a secret value with <redacted> while retaining the parameter name if that name matters. If the exact value or encoding is relevant, reproduce the issue with a test credential or fictional data rather than publishing the secret. Redaction can hide the very difference being debugged, so state which values were changed.
Common Mistakes
- Comparing only the domain and overlooking a different path or API version.
- Assuming duplicate query parameters have one universal interpretation.
- Treating
+,%20, and%2Bas interchangeable in every context. - Assuming query parameter order never matters.
- Concluding that identical URLs mean identical HTTP requests.
- Posting complete request URLs that contain credentials, personal information, or sensitive identifiers.
Best Practices
- Compare exact request data, not remembered or manually retyped URLs.
- Keep a known-good request as a baseline and vary one detail per test.
- Check the API contract for duplicate parameters, required values, and encoding expectations.
- Keep URL comparison separate from checks of method, headers, body, authentication, and server behavior.
- Use fictional or test data in bug reports, and redact secrets before sharing logs or captures.
Conclusion
Comparing a working and failing API URL is a useful first diagnostic step. Break each URL into its components, inspect query details carefully, and test differences one at a time. If the URLs match, move on to the rest of the HTTP request and the server's response; the URL alone cannot explain every failure.
