Class ItemBody

java.lang.Object
com.independentsoft.graph.ItemBody
All Implemented Interfaces:
ICreatable, IUpdatable

public class ItemBody extends Object implements ICreatable, IUpdatable
Represents the body of an item in Microsoft Graph, such as a message, event, or post.

An ItemBody carries the content of an item together with the ContentType that indicates whether the content is plain text or HTML. The default content type is ContentType.TEXT.

Example usage:

 ItemBody body = new ItemBody("<b>Hello</b> world", ContentType.HTML);

 Message message = new Message();
 message.setBody(body);
 
Since:
1.0
See Also:
itemBody resource type, ContentType
  • Constructor Details

    • ItemBody

      public ItemBody()
    • ItemBody

      public ItemBody(String content)
    • ItemBody

      public ItemBody(String content, ContentType contentType)
    • ItemBody

      public ItemBody(JsonObject jsonObject)
  • Method Details

    • toCreateJson

      public String toCreateJson()
      Description copied from interface: ICreatable
      Converts this object to its JSON representation for creation.

      This method generates a JSON string containing all properties needed to create a new instance of this resource in Microsoft Graph. Only properties appropriate for creation should be included (e.g., excluding read-only properties like ID, createdTime, etc.).

      Specified by:
      toCreateJson in interface ICreatable
      Returns:
      JSON string representation for creating this resource
    • toUpdateJson

      public String toUpdateJson()
      Description copied from interface: IUpdatable
      Converts this object to its JSON representation for update.

      This method generates a JSON string containing all modified properties that should be updated in Microsoft Graph. Only writeable properties with non-null values are typically included.

      Specified by:
      toUpdateJson in interface IUpdatable
      Returns:
      JSON string representation for updating this resource
    • toUpdateJson

      public String toUpdateJson(List<String> propertyNames)
      Description copied from interface: IUpdatable
      Converts this object to JSON for update with specific properties.

      This method generates a JSON string containing only the specified properties. This enables partial updates where only certain fields need to be modified, reducing payload size and avoiding unintended changes to other properties.

      Specified by:
      toUpdateJson in interface IUpdatable
      Parameters:
      propertyNames - List of property names to include in the JSON. If null or empty, all modified properties are included.
      Returns:
      JSON string representation for updating specific properties
    • getContent

      public String getContent()
    • setContent

      public void setContent(String content)
    • getContentType

      public ContentType getContentType()
    • setContentType

      public void setContentType(ContentType contentType)