【问题标题】:How to update an entry in Contentful如何更新 Contentful 中的条目
【发布时间】:2018-04-04 00:37:45
【问题描述】:

我没有更新我的条目,在我尝试更新之前,我使用 client.entries().async().unPublish(entry) 取消发布条目,它可以工作,但是当我尝试使用下面的代码更新时,我收到以下消息:@987654322 @

我做错了什么?

 final CMAClient client =
                        new CMAClient
                                .Builder()
                                .setAccessToken(contentfulConnection.getCMA_TOKEN())
                                .build();
     final CMASystem sys = new CMASystem();

    sys.setId(entryID).setVersion(CurrentVersion);  

    CMAEntry entry;
    entry.setField("name", "en-US", "TEST").setSystem(sys); 
    entry.setSpaceId(SPACE_ID);
    entry.setID("entryID");     


    client.entries().async().update(entry, new CMACallback<CMAEntry>() {

                @Override protected void onSuccess(CMAEntry entry) {

                   // Successfully created a new entry.

                   new AlertDialog.Builder(ctx).setTitle("Contentful")                                                                                                                                                                                 
                   .setMessage("Creation of an entry was successful." +"\n\nResult: 
                   " + 
                   entry).show();                                                                                                                                                                                           
    }           }


@Override protected void onFailure(RuntimeException exception) {

    // An error occurred! Inform the user.

    new AlertDialog.Builder(ctx)

    .setTitle("Contentful Error")

    .setMessage("Could not create an entry." +

   "\n\nReason: " + exception.toString())



       .show();

       System.out.println(exception.toString());


       super.onFailure(exception);
                                                                                    }
                                                                                }
                                                                        );

【问题讨论】:

    标签: android contentful


    【解决方案1】:

    我是 Contentful Java SDK 的维护者。

    使用update 方法的推荐方法是首先获取一个项目,更改其数据,然后再次更新。

    如果您点击此链接to our documentation,并选择create/update an entry 按钮,您将看到有关如何更新条目的代码 sn-ps。请选择Android平台查看Android。

    我希望这对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-07-31
      • 2015-10-30
      • 1970-01-01
      • 2021-02-09
      • 2019-11-08
      • 2021-10-05
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      相关资源
      最近更新 更多