【问题标题】:How can I fix this DetailedApiRequestError(status: 404, message: No error details. HTTP status was: 404.)我该如何解决这个DetailedApiRequestError(状态:404,消息:没有错误详细信息。HTTP状态为:404。)
【发布时间】:2020-07-17 13:29:48
【问题描述】:

任何人都知道我做错了什么,我一直收到这个错误

DetailedApiRequestError(status: 404, message: No error details. HTTP status was: 404.)

这是我的代码。


final _credentials = new ServiceAccountCredentials.fromJson(r'''
  {
    "private_key_id": "4XXXXXxXXXXXXXXXXXXXXXXXXXXXXXXXXXXx",
    "private_key": ".....==\n-----END PRIVATE KEY-----\n",
    "client_email": "xxxxxxx@----.com",
    "client_id": "11XXXXXXXXXXXXXX4",
    "type": "service_account"
  }
  ''');

clientViaServiceAccount(_credentials, _SCOPES).then((http_client) {
      var pubSubClient = new PubsubApi(http_client);

      var messages = {
        'messages': [
          {
            'data': base64Encode(utf8.encode('{"foo": "bar"}')),
          },
        ]
      };



      pubSubClient.projects.topics
          .publish(new PublishRequest.fromJson(messages), "your-topic")
          .then((publishResponse) {
        debugPrint(publishResponse.toString());
      }).catchError((e,m){
        debugPrint(e.toString());
      });
    });

我在initState() 中有一个带有此代码的有状态小部件,当我运行它时出现上述错误。当我检查我的谷歌云时,没有发布任何内容。任何可以快速帮助我的人。

【问题讨论】:

    标签: flutter dart google-api


    【解决方案1】:

    所以这是一个解决方案,改变这个:

    
    pubSubClient.projects.topics
              .publish(new PublishRequest.fromJson(messages), "your-topic")
              .then((publishResponse) {
            debugPrint(publishResponse.toString());
          }).catchError((e,m){
            print(m.toString());
            debugPrint(e.toString());
          });
    
    

    到这里:

    
        pubSubClient.projects.topics
              .publish(new PublishRequest.fromJson(messages), "projects/projectIDXX/topics/yourTopic")
              .then((publishResponse) {
            debugPrint(publishResponse.toString());
          }).catchError((e,m){
            print(m.toString());
            debugPrint(e.toString());
          });
    

    问题在于主题。

    【讨论】:

      猜你喜欢
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-10
      • 2016-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多