You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Important**: Custom REST APIs require explicit configuration. Unlike built-in Amplify resources (Auth, Data), custom APIs are not automatically included when calling `Amplify.configure(outputs)`.
211
+
212
+
</Callout>
213
+
207
214
To initialize the Amplify API category you need to configure Amplify with `Amplify.configure()`.
208
215
209
216
Importandloadtheconfigurationfileinyourapp. It's recommended you add the Amplify configuration step to your app'srootentrypoint. Forexample`index.js`inReactor`main.ts`inAngular.
@@ -221,7 +228,7 @@ Amplify.configure(
221
228
...amplifyConfig,
222
229
API: {
223
230
...amplifyConfig.API,
224
-
REST:outputs.custom.API,
231
+
REST:outputs.custom.API,// ← Required for custom REST APIs
225
232
},
226
233
},
227
234
{
@@ -250,7 +257,7 @@ Amplify.configure(
250
257
...amplifyConfig,
251
258
API: {
252
259
...amplifyConfig.API,
253
-
REST: outputs.custom.API,
260
+
REST: outputs.custom.API,// ← Required for custom REST APIs
254
261
},
255
262
},
256
263
{
@@ -271,4 +278,40 @@ Amplify.configure(
271
278
Make sure you call `Amplify.configure` as early as possible in your application’s life-cycle. A missing configuration or `NoCredentials` error is thrown if `Amplify.configure` has not been called before other Amplify JavaScript APIs. Review the [Library Not Configured Troubleshooting guide](/[platform]/build-a-backend/troubleshooting/library-not-configured/) for possible causes of this issue.
272
279
273
280
</Callout>
281
+
282
+
<Calloutwarning="true">
283
+
284
+
**Critical Configuration Step**: The line `REST: outputs.custom.API` is **required** to register your custom REST API. Without this, you'll encounter the error `API name is invalid` when trying to call your API.
285
+
286
+
</Callout>
287
+
288
+
## Troubleshooting
289
+
290
+
### "API name is invalid" Error
291
+
292
+
If you encounter the error `API name is invalid` when calling your REST API, ensure you have:
293
+
294
+
1.**Added the custom API configuration**: Include `REST: outputs.custom.API` in your `Amplify.configure()` call
295
+
2.**Used the correct API name**: The API name should match the `restApiName` defined in your `backend.ts` file
296
+
3.**Called `Amplify.configure()`**: Make sure configuration happens before any API calls
297
+
298
+
**Example of incorrect configuration** (missing custom API):
299
+
```javascript
300
+
// ❌ This will cause "API name is invalid" error
301
+
Amplify.configure(outputs); // Missing custom REST API configuration
302
+
```
303
+
304
+
**Correct configuration**:
305
+
```javascript
306
+
// ✅ This includes custom REST APIs
307
+
constamplifyConfig=parseAmplifyConfig(outputs);
308
+
Amplify.configure({
309
+
...amplifyConfig,
310
+
API: {
311
+
...amplifyConfig.API,
312
+
REST:outputs.custom.API, // Required for custom APIs
0 commit comments