【问题标题】:In AWS Amplify Android, why does Amplify.API.post() make a GET request?在 AWS Amplify Android 中,为什么 Amplify.API.post() 会发出 GET 请求?
【发布时间】:2020-05-27 15:41:45
【问题描述】:

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

我创建插件

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 工作得很好。

【问题讨论】:

    标签: android amazon-web-services aws-amplify rest


    【解决方案1】:

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

    原来这是一个错误。有一个简单的解决方法,只需添加一个空主体

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      • 2012-06-28
      • 1970-01-01
      • 2020-12-25
      相关资源
      最近更新 更多