Skip to content

Commit ed23408

Browse files
committed
added PATCH example
1 parent 5678165 commit ed23408

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

graph/patterns/viewpoint.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This pattern simplifies the API client logic by hiding the state transition deta
2424
</Annotations>
2525
```
2626
- An alternative to this design would be to store the user state on the client side. However, this may be problematic in some cases, because of the many devices that a user may have and the need to synchronize the state across them.
27+
- Often, updating the `viewpoint` property may cause a side effect, so you might consider an OData action to do the update. For some user scenarios, the `PATCH` method could be a better way to update a `viewpoint`.
2728

2829
## Examples
2930

@@ -70,7 +71,8 @@ Content-type: application/json
7071
"lastUpdatedDateTime": "2020-12-08T23:58:32.511Z",
7172
"chatType": "meeting",
7273
"viewpoint":{
73-
"lastMessageReadDateTime": "2021-03-28T21:10:00.000Z" // User has unread messages
74+
"lastMessageReadDateTime": "2021-03-28T21:10:00.000Z"
75+
// User has unread messages
7476
}
7577
},
7678
{
@@ -80,17 +82,16 @@ Content-type: application/json
8082
"lastUpdatedDateTime": "2020-12-08T23:53:11.012Z",
8183
"chatType": "group",
8284
"viewpoint":{
83-
"lastMessageReadDateTime": "0000-01-01T00:00:00.000Z" // User hasnt read anything since no message was posted
85+
"lastMessageReadDateTime": "0000-01-01T00:00:00.000Z"
86+
// User hasnt read anything since no message was posted
8487
}
8588
}
8689
]
8790
}
8891
```
89-
### Updating a viewpoint
92+
### Updating a viewpoint using an action
9093

91-
You can update the `viewpoint` property only if the server does not compute it automatically. Updating the `viewpoint` property usually has a side effect, so you may want to use an OData action to perform the update.
92-
93-
The following example shows marking a chat as read for a user:
94+
The following example shows marking a chat `viewpoint` as read for a user using an action:
9495

9596
```http
9697
@@ -105,8 +106,31 @@ Content-length: 106
105106
}
106107
}
107108
```
109+
108110
The server responds with a success status code and no payload:
109111

110112
```http
111113
HTTP/1.1 204 No Content
112114
```
115+
### Updating a viewpoint using `PATCH` method
116+
117+
The following example shows how to mark a topic with the `viewpoint` label as reviewed for a user by using the `PATCH` method (this example does not represent an actual API, but only an illustration):
118+
119+
```
120+
PATCH https://graph.microsoft.com/beta/sampleTopics/19:7d898072-792c-4006-bb10-5ca9f259
121+
122+
HTTP/1.1 200 OK
123+
Content-Type: application/json
124+
125+
{
126+
"title": "Announcements: Changes to PowerPoint and Word to open files faster",
127+
...
128+
"viewpoint": {
129+
"isReviewed" : "true"
130+
}
131+
}
132+
The server responds with a success status code and no payload:
133+
134+
```http
135+
HTTP/1.1 204 No Content
136+
```

0 commit comments

Comments
 (0)