ToDo task body is text and missing HTML formatting

Kevin Weslowski 1 Reputation point
2022-09-17T18:11:51.067+00:00

When I use the Graph Explorer
https://developer.microsoft.com/en-us/graph/graph-explorer

to query a task that I created in Microsoft To Do, the body contentType is always text and the HTML formatting (i.e. line breaks) are missing.

https://learn.microsoft.com/en-us/graph/api/resources/todotask?view=graph-rest-1.0

For example, I created a task in Microsoft To Do and put two lines in the body content:

line one  
  
line two  

And I clearly separated them by two line breaks in the Microsoft To Do body edit window. When I query the task using Graph Explorer, the JSON response looks like this:

"body": {
"content": "line oneline two",
"contentType": "text"
}

Shouldn't the contentType be "html" and shouldn't there be my line breaks between "line one" and "line two" instead of the no separation in the JSON response?

Microsoft Security Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-09-23T16:26:51.05+00:00

    Hi @Kevin Weslowski ,

    To get response in HTML format use the Prefer: outlook.body-content-type="html" Request headers.
    Example usage of API:

    GET /users/{id|userPrincipalName}/todo/lists/{todoTaskListId}/tasks  
    Prefer : outlook.body-content-type="html"  
    

    My test results:
    244373-image.png

    Graph API request:
    244359-image.png

    Response in HTML:
    244384-image.png

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.