0

Can someone offer guidance on why the following code does not update the title field of a SharePoint list item?

public void setItemTitle(String siteId, String listId, ListItem item)
{
    ListItem updateItem = new ListItem();
    var  updateRequest = graph.getGraphClient().sites(siteId).lists(listId).items(item.id).fields().buildRequest();

    updateRequest.addHeader("If-Match", item.getRawObject().get("@odata.etag").getAsString());
    updateRequest.addHeader("prefer", "return=representation");

    JsonObject json= new JsonObject();
    json.addProperty("Title", "updated title");

    FieldValueSet fieldValueSet =  new FieldValueSet();
    fieldValueSet.setRawObject(null, json);


    FieldValueSet response = updateRequest.patch(fieldValueSet);
}

The field does not get updated in the response object, nor in SharePoint. Thanks in advance

1 Answer 1

0

For anyone else trying to get this working:

    IFieldValueSetRequest updateRequest = graph.getGraphClient().sites(siteId).lists(listId).items(item.id).fields().buildRequest();
    FieldValueSet fieldValueSet =  new FieldValueSet();
    fieldValueSet.additionalDataManager().put("Title", new JsonPrimitive("new Title value"));
    FieldValueSet response = updateRequest.patch(fieldValueSet);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.