简体   繁体   English

如何修复此DetailedApiRequestError(状态:404,消息:没有错误详细信息。HTTP 状态为:404。)

[英]How can I fix this DetailedApiRequestError(status: 404, message: No error details. HTTP status was: 404.)

anybody knows what I'm doing wrong, I keep getting this error任何人都知道我做错了什么,我一直收到这个错误

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

Here's my code.这是我的代码。


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());
      });
    });

I have a stateful widget with this code in initState() , when I run it I get the error above.我在initState()中有一个带有此代码的有状态小部件,当我运行它时,我收到上面的错误。 when I check my google cloud nothing is published.当我检查我的谷歌云时,没有发布任何内容。 Anyone who can help me quickly.任何可以快速帮助我的人。

So this here a solution, change this:所以这是一个解决方案,改变这个:


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

to this:对此:


    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());
      });

The issue was with topic.问题与主题有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 I/flutter (28276):此处发现错误 DioError [DioErrorType.response]:Http 状态错误 [404] - I/flutter (28276): Error found Here DioError [DioErrorType.response]: Http status error [404] DioError [DioErrorType.response] Http 状态错误 [404] - flutter - DioError [DioErrorType.response] Http status error [404] - flutter DioError [DioErrorType.RESPONSE]:Http 状态错误 [404] - DioError [DioErrorType.RESPONSE]: Http status error [404] 在 cachedNetworkImage 崩溃 APP 中出现 404 状态错误 - Getting 404 status error in cachedNetworkImage crashing APP 如果登录后收到 404 状态码,如何设置我的应用程序? - how to do the setup for my app if i get 404 status code after login? 包和“代码”:404,“消息”:“未找到。无法获取对象”,“状态”:“GET_OBJECT”}不允许使用 DTS、ODTC - DTS, ODTC are not allowed for Package and "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" } GET api 在 flutter 失败,I/flutter (4017): {code: 404, message: HTTP 404 Not Found} - GET api in flutter failing with I/flutter ( 4017): {code: 404, message: HTTP 404 Not Found} Flutter web:某些 png 资源未加载 (404) 状态 - Flutter web: Some png assets not loaded (404) status 我该如何解决 dio https 状态 401 错误? - how can i solve dio https status 401 error? 如何查看屏幕点击状态? - How can I check the screen click status?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM