reaction icon indicating copy to clipboard operation
reaction copied to clipboard

Add Error Handling Examples for /users/info in Documentation

Open RickDeb2004 opened this issue 10 months ago • 2 comments

Issue Description

Image

The documentation for the /users/info endpoint in the Mailchimp Transactional API (https://mailchimp.com/developer/transactional/api/users/) lacks examples of error responses, making it difficult for developers to implement proper error handling. When calling /users/info with an invalid API key or under rate-limiting conditions, the API returns errors, but the specific response formats (e.g., JSON structure, HTTP status codes) are not documented. For example, an invalid API key might return {"error": "Invalid API key", "code": 401}, but this isn’t specified. This omission leads to trial-and-error debugging and potential integration failures in production.

Expected behavior: The documentation should include a section with sample error responses (e.g., 401 Unauthorized, 429 Too Many Requests) alongside success examples, similar to other well-documented APIs.

Steps to Reproduce

  1. Use a Node.js client (e.g., @mailchimp/mailchimp-transactional) or cURL to call the /users/info endpoint with an invalid API key:
    curl -X GET "https://mandrillapp.com/api/1.0/users/info.json" --data "key=INVALID_KEY"
    

RickDeb2004 avatar Feb 21 '25 11:02 RickDeb2004

Hey let me try to fix this issue. The current response I have get is look like below by sample test if you like the given format assign me to focus on it more specifically

Starting API Error Response Documentation...

Documenting Mailchimp Transactional API Error Responses

Test Case 1: Invalid API Key

API Response Documentation: HTTP Status Code: 401 Response Headers: { 'access-control-allow-credentials': 'false', 'access-control-allow-headers': 'Content-Type', 'access-control-allow-methods': 'POST, GET, OPTIONS', 'access-control-allow-origin': '*', connection: 'keep-alive', 'content-encoding': 'gzip', 'content-type': 'application/json; charset=utf-8', date: 'Mon, 17 Mar 2025 16:01:29 GMT', server: 'nginx', 'transfer-encoding': 'chunked', vary: 'Accept-Encoding' } Response Body: { "status": "error", "code": 401, "name": "Invalid_Key", "message": "Invalid API key" }

Error Response Structure:

  • Status Code: 401
  • Error Name: Invalid_Key
  • Status: error
  • Error Code: 401
  • Message: Invalid API key

Test Case 2: Rate Limiting Detection Making multiple rapid requests to detect rate limiting...

Rate Limiting Analysis:

Request 1: Status Code: 401 Rate Limit Headers: { 'x-ratelimit-limit': undefined, 'x-ratelimit-remaining': undefined, 'x-ratelimit-reset': undefined } Response: { "status": "error", "code": 401, "name": "Invalid_Key", "message": "Invalid API key" }

Request 2: Status Code: 401 Rate Limit Headers: { 'x-ratelimit-limit': undefined, 'x-ratelimit-remaining': undefined, 'x-ratelimit-reset': undefined } Response: { "status": "error", "code": 401, "name": "Invalid_Key", "message": "Invalid API key" }

Request 3: Status Code: 401 Rate Limit Headers: { 'x-ratelimit-limit': undefined, 'x-ratelimit-remaining': undefined, 'x-ratelimit-reset': undefined } Response: { "status": "error", "code": 401, "name": "Invalid_Key", "message": "Invalid API key" }

Request 4: Status Code: 401 Rate Limit Headers: { 'x-ratelimit-limit': undefined, 'x-ratelimit-remaining': undefined, 'x-ratelimit-reset': undefined } Response: { "status": "error", "code": 401, "name": "Invalid_Key", "message": "Invalid API key" }

samadhanmane avatar Mar 17 '25 16:03 samadhanmane

I'd like to work on this issue. It looks like it's still unassigned and no pull request has been submitted yet. If it's okay, I’ll start working on it and open a PR soon.

Please let me know if there are any specific guidelines you'd like me to follow. Thanks!

sejalkailashyadav avatar Aug 04 '25 07:08 sejalkailashyadav