|
1 | 1 | ---
|
2 | 2 | keywords: ['api', 'error', 'client']
|
3 |
| -slug: /api-troubleshooting-client-server-errors-during-the-api-call |
| 3 | +slug: /client-server-errors-during-the-api-call |
4 | 4 | title: Client-Server Errors during the API call
|
5 | 5 | ---
|
6 | 6 | # Client-Server Errors During the API Call
|
7 | 7 |
|
8 | 8 |
|
9 |
| -When working with APIs, one of the most common hurdles developers face is understanding and resolving errors that occur during the interaction between a client and a server. Whether you're building, integrating, or consuming APIs, it's important to recognize what different error codes mean and how to fix them. These errors are typically categorized as client-side or server-side, each with its own set of HTTP status codes. |
| 9 | +When calling an API in FlutterFlow, you may run into client-server errors. These typically come as status codes that indicate what went wrong—either on your end (the client) or on the server you're requesting data from. |
10 | 10 |
|
11 |
| -This guide will walk you through the most common client-server error codes encountered during API calls, explain what they mean, and offer practical tips for diagnosing and resolving them effectively. Whether you're a beginner trying to understand what a 404 error really means or an experienced developer dealing with elusive 5XX responses, this article will help you decode the problem and get your API calls back on track. |
| 11 | +This guide will help you understand the most common API error codes and how to fix them. |
12 | 12 |
|
13 |
| -## Application Programming Interfaces (APIs) |
| 13 | +## What is an API? |
14 | 14 |
|
15 |
| -APIs allow two programs to communicate and transfer data. An API call is when a client application submits a request to an API, which retrieves the requested data from an external server or program and delivers it back to the client. |
| 15 | +An API (Application Programming Interface) lets two systems communicate with each other. When you make an API call, you're sending a request from your app (client) to a server, which responds with data. |
16 | 16 |
|
17 |
| ---- |
| 17 | +## Common client-side status codes |
18 | 18 |
|
19 |
| -## Error Status Codes When Building APIs |
| 19 | +These errors are usually caused by incorrect requests from the client side. |
20 | 20 |
|
21 |
| -### 1. Client-Side Status Codes |
| 21 | +- **400 – Bad request** |
22 | 22 |
|
23 |
| -- #### 404 Not Found |
24 |
| - This is the most common HTTP status code. It indicates that the URL used in your request doesn’t exist on the API server or origin server. While this is a 4XX error (usually meaning something on the client-side is wrong), it can also indicate a server problem. Sometimes API URL paths change after a version update, or due to server issues. |
| 23 | + Your request isn’t properly formatted. This could be due to a missing parameter, a typo, or incorrect syntax. |
25 | 24 |
|
26 | 25 | :::tip
|
27 |
| - Check for typos in your client code before investigating API issues. |
| 26 | + Check the API documentation to ensure you're including the correct fields and headers. |
28 | 27 | :::
|
29 | 28 |
|
30 |
| -  |
| 29 | +  |
31 | 30 |
|
32 |
| -- #### 401 Unauthorized |
33 |
| - This status code means you haven’t authenticated against the API. The API doesn’t know who you are and won’t serve you. For most APIs, you need to sign up and get an API key, which is used in an HTTP header field when sending a request. |
| 31 | +- **401 – Unauthorized** |
34 | 32 |
|
35 |
| - This is similar to the less common **407 Proxy Authentication Required**, which means you haven’t authenticated with the proxy. |
| 33 | + You didn’t provide the correct credentials (like an API key). Most APIs require authentication via headers. |
36 | 34 |
|
37 | 35 | 
|
38 | 36 |
|
39 |
| -- #### 403 Forbidden |
40 |
| - This status indicates you don’t have permission to request that URL. You’re authenticated, but your user or role isn’t permitted to make the API request. This can also occur if you use the wrong API key or try to access features not allowed by your subscription plan. |
| 37 | +- **403 – Forbidden** |
| 38 | + |
| 39 | + You’re authenticated, but you don’t have permission to access the resource. This could be due to API plan restrictions or role-based access. |
41 | 40 |
|
42 | 41 | 
|
43 | 42 |
|
44 |
| -- #### 400 Bad Request |
45 |
| - The *400 Bad Request* error is generic. It means your API request was not correctly formatted. If no additional error information is given in the response body, check the docs. You could be missing a query, a field in the request body, or a header field could be wrong. Incorrect syntax in your request data can also cause this. |
| 43 | +- **404 – Not found** |
46 | 44 |
|
47 |
| - This differs from the *422 Unprocessable Entity* error, which appears when your request is correctly formatted but cannot be processed. For example, passing a badly formatted `latlang` value to the API (e.g., missing a comma). |
| 45 | + The URL you’re requesting doesn’t exist. This could be due to a typo or a deprecated API endpoint. |
48 | 46 |
|
49 |
| -  |
| 47 | + :::tip |
| 48 | + Always double-check your request URL before troubleshooting further. |
| 49 | + ::: |
| 50 | + |
| 51 | +  |
| 52 | + |
| 53 | +- **407 – Proxy authentication required** |
| 54 | + |
| 55 | + You haven't authenticated with the proxy server. This is less common but can happen in restricted network environments. |
| 56 | + |
| 57 | +- **422 – Unprocessable entity** |
50 | 58 |
|
51 |
| -- #### 429 Too Many Requests |
52 |
| - Most API subscription plans have limits—the cheaper the plan, the fewer requests per second are allowed for your API key. If you send too many requests in a short time, consider throttling them in your client. This response can also indicate you hit a daily, weekly, or monthly limit on your account. |
| 59 | + Your request was well-formed but couldn’t be processed. For example, passing a `latlng` without a comma. |
| 60 | + |
| 61 | +- **429 – Too many requests** |
| 62 | + |
| 63 | + You’ve hit your rate limit. Most APIs restrict the number of requests you can make in a certain timeframe. |
53 | 64 |
|
54 | 65 | :::tip
|
55 |
| - Check your API subscription limits before integrating, or you may run into problems later. |
| 66 | + Check your API plan limits and consider throttling requests from your app. |
56 | 67 | :::
|
57 |
| ---- |
58 | 68 |
|
59 |
| -### 2. Server-Side Status Codes |
| 69 | +## Common server-side status codes |
60 | 70 |
|
61 |
| -Sometimes, server-side API errors occur. Here are common ones: |
| 71 | +These errors occur on the API server side. |
62 | 72 |
|
63 |
| -- #### 500 Internal Server Error |
64 |
| - This code can mean anything, but usually indicates the API server crashed. It could be caused by your API call or by buggy code/data from an upstream service. Double-check the docs for correct query fields, body fields, headers, and format. If the problem persists, contact the API’s support. |
| 73 | +- **500 – Internal server error** |
65 | 74 |
|
66 |
| -- #### 502 Bad Gateway |
67 |
| - This response means the server you called was a gateway or proxy, not the actual API server. The proxy tried to call the API server but didn’t get a response. This could be a network problem, server crash, or maintenance. Usually, this is temporary and should be solved by the API provider. |
| 75 | + The server ran into an unexpected issue. Double-check your request, but if it looks fine, the problem is likely on the server side. |
68 | 76 |
|
69 |
| -- #### 503 Service Unavailable |
70 |
| - This status indicates a server error—too many API requests were sent and the API can’t handle more. The problem usually resolves itself when clients send fewer requests, but it could also mean the API provider didn’t plan enough resources. If the error persists, contact the API provider. |
| 77 | +- **501 – Not implemented** |
71 | 78 |
|
72 |
| -- #### 504 Gateway Timeout |
73 |
| - Like 502, this means the server you called is a proxy for the real API server, but the API server took too long to respond. This could be due to high network latency or a slow API server. Try reducing the amount of data or complexity of your request. If the error persists, contact support. |
| 79 | + The HTTP method you're using (example, PUT or PATCH) isn't supported by the API yet. |
74 | 80 |
|
75 |
| -- #### 501 Not Implemented |
76 |
| - This status code is related to the HTTP method you used. Try a different HTTP method. Usually, an inappropriate method results in a 404, but 501 means the method isn’t implemented yet and may be available in the future. |
| 81 | +- **502 – Bad gateway** |
77 | 82 |
|
78 |
| ---- |
| 83 | + The API server is using a gateway or proxy, and it failed to get a valid response from the upstream server. Usually a temporary issue. |
79 | 84 |
|
80 |
| -You’ll encounter many error codes when using APIs, but most have reasonable fixes. Some are server errors, some are client-side errors, and often one can cause the other. |
| 85 | +- **503 – Service unavailable** |
81 | 86 |
|
| 87 | + The API server is overloaded or undergoing maintenance. Try again later. |
82 | 88 |
|
83 |
| -:::tip |
84 |
| -Always read the docs and API notes thoroughly. If things are broken, contact the API provider or search for answers on the web (e.g., StackOverflow). Stay determined, and you’ll see your 200 OK status codes in no time! |
85 |
| -::: |
| 89 | +- **504 – Gateway timeout** |
86 | 90 |
|
| 91 | + The API server took too long to respond. Try simplifying your request or reducing the size of the data being sent. |
87 | 92 |
|
| 93 | +:::tip[Final tips] |
| 94 | +- Always check the API documentation, inspect your request, and look up error messages. If the issue persists, contact the API provider. |
| 95 | +- Once you fix the issue, your calls should return a `200 OK`—which means everything is working as expected! |
| 96 | +::: |
0 commit comments