在 AWS Amplify Android 中,为什么 Amplify.API.post() 发出 GET 请求?

In AWS Amplify Android, why does Amplify.API.post() make a GET request?

所以,我有一个简单的 REST API 用 AWS Amplify Android 实现的。

我创建插件

try {
    Amplify.addPlugin(new AWSApiPlugin());
    Amplify.configure(getApplicationContext());
    Log.i("AmplifyGetStarted", "Amplify is ready for use!");
} catch (AmplifyException configurationFailure) {
    Log.e("AmplifyGetStarted", "Failed to configure Amplify", configurationFailure);
}

然后,当我这样做时:

RestOptions addCard =
    new RestOptions("/cards/" + userid + "/" + card.id);
Amplify.API.post("apipacaward", addCard,
    restResponse -> Log.i(TAG, restResponse.getData().asString()),
    apiFailure -> Log.e("ApiQuickStart", apiFailure.getMessage(), apiFailure)
);

响应是:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Error</title>
  </head>
  <body>
    <pre>Cannot GET /cards/8f8cffd1-b0b4-4fc3-b39a-f0001d7981eb/397e3a23-c8e5-496b-8082-49267aa08510</pre>
  </body>
</html>

我确定这是对这个端点的 GET 请求的响应,因为我已经在邮递员中进行了测试。此外,在邮递员上,POST 工作得很好。

https://github.com/aws-amplify/amplify-android/issues/538

事实证明这是一个错误。有一个简单的解决方法,只需添加一个空主体