Skip to content

Commit f1208c1

Browse files
committed
improved formatting and updated content.
1 parent ae0d11a commit f1208c1

5 files changed

+151
-108
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
keywords: ['api', 'encoding', 'charset']
3+
slug: /api-charset-and-encoding-fix-guide
4+
title: API Charset and Encoding Fix Guide
5+
---
6+
# API Charset and Encoding Fix Guide
7+
8+
When working with API calls in FlutterFlow, you might encounter issues where the response returns with strange characters, incorrect formatting, or unreadable content. These problems are often caused by improper charset or encoding settings either in the API request or the server response.
9+
10+
This guide shows you how to resolve such issues and ensure your API outputs are correctly displayed in your FlutterFlow project.
11+
12+
Follow the steps below:
13+
14+
- **Set Proper Request Headers**
15+
16+
Make sure your API call includes the appropriate headers to instruct the server on how to format the response. Add the following headers to your API configuration:
17+
18+
`Content-Type: application/json`
19+
20+
`Charset: utf-8`
21+
22+
23+
These headers tell the server to return the data in JSON format using UTF-8 encoding, which is compatible with FlutterFlow.
24+
25+
![Setting Content-Type and Charset headers](../assets/20250430121409119593.png)
26+
27+
- **Enable UTF-8 Decoding in FlutterFlow**
28+
29+
If the server does not specify encoding—or if you're still getting corrupted text—you can configure FlutterFlow to decode the API response as UTF-8 manually.
30+
31+
To do this:
32+
33+
1. Go to your API call setup in FlutterFlow.
34+
2. Scroll to **Advanced Settings**.
35+
3. Enable **Force response decoding as UTF-8**.
36+
37+
This setting helps FlutterFlow correctly interpret the API response, especially from servers that don’t return standard headers.
38+
39+
![Force decode response as UTF-8](../assets/20250430121409391507.png)
40+
41+
42+
:::tip[Final Tips]
43+
- Always test your API calls in FlutterFlow’s API Test tab to ensure the response is properly formatted.
44+
- Confirm that the external API supports UTF-8 and returns a valid JSON response.
45+
- Review your server settings if you control the backend, to ensure it sends the correct headers.
46+
:::
47+
48+
:::note
49+
Incorrect API call outputs due to charset or encoding can be quickly resolved by:
50+
- Adding proper headers like `Content-Type: application/json` and `Charset: utf-8`.
51+
- Enabling **Force response decoding as UTF-8** in FlutterFlow’s API advanced settings.
52+
These simple steps will help you get accurate and readable data from your APIs, resulting in a smoother app development experience.
53+
:::
54+
55+
If you still face challenges, don't hesitate to reach out to our support team through Live chat or by emailing [email protected]
Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,96 @@
11
---
22
keywords: ['api', 'error', 'client']
3-
slug: /api-troubleshooting-client-server-errors-during-the-api-call
3+
slug: /client-server-errors-during-the-api-call
44
title: Client-Server Errors during the API call
55
---
66
# Client-Server Errors During the API Call
77

88

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.
1010

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.
1212

13-
## Application Programming Interfaces (APIs)
13+
## What is an API?
1414

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.
1616

17-
---
17+
## Common client-side status codes
1818

19-
## Error Status Codes When Building APIs
19+
These errors are usually caused by incorrect requests from the client side.
2020

21-
### 1. Client-Side Status Codes
21+
- **400 – Bad request**
2222

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.
2524

2625
:::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.
2827
:::
2928

30-
![404 Example](../assets/20250430121350517804.png)
29+
![400 Example](../assets/20250430121351345482.png)
3130

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**
3432

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.
3634

3735
![401 Example](../assets/20250430121350799148.png)
3836

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.
4140

4241
![403 Example](../assets/20250430121351077308.png)
4342

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**
4644

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.
4846

49-
![400 Example](../assets/20250430121351345482.png)
47+
:::tip
48+
Always double-check your request URL before troubleshooting further.
49+
:::
50+
51+
![404 Example](../assets/20250430121350517804.png)
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**
5058

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.
5364

5465
:::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.
5667
:::
57-
---
5868

59-
### 2. Server-Side Status Codes
69+
## Common server-side status codes
6070

61-
Sometimes, server-side API errors occur. Here are common ones:
71+
These errors occur on the API server side.
6272

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**
6574

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.
6876

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**
7178

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.
7480

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**
7782

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.
7984

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**
8186

87+
The API server is overloaded or undergoing maintenance. Try again later.
8288

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**
8690

91+
The API server took too long to respond. Try simplifying your request or reducing the size of the data being sent.
8792

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+
:::

docs/troubleshooting/api/fixing_incorrect_api_call_outputs_due_to_charset_and_encoding.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/troubleshooting/api/securing_your_api_keys_in_private_api_calls.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,39 @@ Ensuring the security of API keys is a critical aspect of building and maintaini
1212

1313
Many users assume that simply marking an API call as 'private' is enough to protect all associated data. However, this is not the case. Private API calls run in a Cloud Function, which means any keys or sensitive data in the body will be secure — as long as they're not passed in from the frontend. Even in private API calls, if you're loading an API key from the frontend (like from Firebase remote configs), then you're still exposing it.​
1414

15-
### Where to Put Your API Keys
15+
## Where to Put Your API Keys
1616

17-
The ideal way to secure an API key is to include it in a request header or directly within the API endpoint URL. This ensures that it is never passed in from the client, thereby maintaining its confidentiality.​
18-
For example, you can hard-code the key directly into your API call header like this:​
17+
The ideal way to secure an API key is to include it in a request header or directly within the API endpoint URL. This ensures that it is never passed in from the client, thereby maintaining its confidentiality.​
1918

20-
```
21-
{ "Authorization": "Bearer YOUR_API_KEY_HERE" }
22-
```
19+
For example, you can hard-code the key directly into your API call header like this:​
2320

24-
Or directly within the API endpoint URL:​
21+
```js
22+
{ "Authorization": "Bearer YOUR_API_KEY_HERE" }
23+
```
2524

26-
```
27-
https://api.example.com/resource?api_key=YOUR_API_KEY_HERE
28-
```
29-
The key should never be a variable that gets passed in from the frontend, as that would make it accessible via the client-side code, defeating the purpose of using private API calls for secure operations.
25+
Or directly within the API endpoint URL:​
3026

31-
### Verification
27+
```js
28+
https://api.example.com/resource?api_key=YOUR_API_KEY_HERE
29+
```
30+
The key should never be a variable that gets passed in from the frontend, as that would make it accessible via the client-side code, defeating the purpose of using private API calls for secure operations.
3231

33-
After implementing these changes, a straightforward way to verify that your key is secured is by downloading your application code and checking to make sure the API key doesn’t appear in any frontend files.​
32+
## How to verify that your key is secured
3433

35-
Example: Not Secure
34+
After implementing these changes, a straightforward way to verify that your key is secured is by downloading your application code and checking to make sure the API key doesn’t appear in any frontend files.​
3635

37-
![](../assets/20250430121157297846.png)
36+
Example: Not Secure
3837

39-
Example: More Secure
38+
![](../assets/20250430121157297846.png)
4039

41-
![](../assets/20250430121157601185.png)
40+
Example: More Secure
4241

42+
![](../assets/20250430121157601185.png)
4343

44-
By adhering to these best practices, you can increase the safety of your API keys even while making private API calls. Remember, the goal is to keep all sensitive data, including API keys, away from the client side of the application to ensure optimal security.
4544

45+
By adhering to these best practices, you can increase the safety of your API keys even while making private API calls.
46+
47+
:::info
48+
The goal is to keep all sensitive data, including API keys, away from the client side of the application to ensure optimal security.
49+
:::
4650

0 commit comments

Comments
 (0)