Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "acl": [
// {
// "type": "everyone",
// "value": "c5f19b2d-0a77-454a-9b43-abf298c3b34e",
// "accessType": "grant"
// }
// ],
// "properties": {
// "title": "Sample item title",
// "extension": "docx",
// "createdBy": "John Doe",
// "createdDateTime": "2021-04-27T11:04:00Z",
// "iconUrl": "https://contentdepot.blob.core.windows.net/filedepot/sampleIconUrl.png",
// "authors": [
// "John Doe"
// ],
// "authors@odata.type": "Collection(String)",
// "lastModifiedDate": "2021-04-27T11:04:00Z",
// "url": "https://sampleItemUrl.com",
// "containerName": "Sample container name",
// "containerUrl": "https://sampleContainerUrl.com"
// },
// "content": {
// "type": "text",
// "value": "Empower customers and partners to be more productive by enabling them to bring content and activity information and allow external content to participate in Microsoft Search and OfficeHub experiences so that they find relevant and actionable information across all their applications."
// }
// }
CkJsonObjectW json;
json.UpdateString(L"acl[0].type",L"everyone");
json.UpdateString(L"acl[0].value",L"c5f19b2d-0a77-454a-9b43-abf298c3b34e");
json.UpdateString(L"acl[0].accessType",L"grant");
json.UpdateString(L"properties.title",L"Sample item title");
json.UpdateString(L"properties.extension",L"docx");
json.UpdateString(L"properties.createdBy",L"John Doe");
json.UpdateString(L"properties.createdDateTime",L"2021-04-27T11:04:00Z");
json.UpdateString(L"properties.iconUrl",L"https://contentdepot.blob.core.windows.net/filedepot/sampleIconUrl.png");
json.UpdateString(L"properties.authors[0]",L"John Doe");
json.UpdateString(L"properties.\"authors@odata.type\"",L"Collection(String)");
json.UpdateString(L"properties.lastModifiedDate",L"2021-04-27T11:04:00Z");
json.UpdateString(L"properties.url",L"https://sampleItemUrl.com");
json.UpdateString(L"properties.containerName",L"Sample container name");
json.UpdateString(L"properties.containerUrl",L"https://sampleContainerUrl.com");
json.UpdateString(L"content.type",L"text");
json.UpdateString(L"content.value",L"Empower customers and partners to be more productive by enabling them to bring content and activity information and allow external content to participate in Microsoft Search and OfficeHub experiences so that they find relevant and actionable information across all their applications.");
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken(L"<access_token>");
http.SetRequestHeader(L"Content-Type",L"application/json");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkHttpResponseW *resp = http.PTextSb(L"PUT",L"https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/items/sampleItemId",sbRequestBody,L"utf-8",L"application/json",false,false);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"%d\n",resp->get_StatusCode());
wprintf(L"%s\n",resp->bodyStr());
delete resp;
}
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"acl": [
{
"type": "everyone",
"value": "c5f19b2d-0a77-454a-9b43-abf298c3b34e",
"accessType": "grant"
}
],
"properties": {
"title": "Sample item title",
"extension": "docx",
"createdBy": "John Doe",
"createdDateTime": "2021-04-27T11:04:00Z",
"iconUrl": "https://contentdepot.blob.core.windows.net/filedepot/sampleIconUrl.png",
"authors": [
"John Doe"
],
"authors@odata.type": "Collection(String)",
"lastModifiedDate": "2021-04-27T11:04:00Z",
"url": "https://sampleItemUrl.com",
"containerName": "Sample container name",
"containerUrl": "https://sampleContainerUrl.com"
},
"content": {
"type": "text",
"value": "Empower customers and partners to be more productive by enabling them to bring content and activity information and allow external content to participate in Microsoft Search and OfficeHub experiences so that they find relevant and actionable information across all their applications."
}
}'
https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/items/sampleItemId
Postman Collection Item JSON
{
"name": "Put item",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"acl\": [\r\n {\r\n \"type\": \"everyone\",\r\n \"value\": \"c5f19b2d-0a77-454a-9b43-abf298c3b34e\",\r\n \"accessType\": \"grant\"\r\n }\r\n ],\r\n \"properties\": {\r\n \"title\": \"Sample item title\",\r\n \"extension\": \"docx\",\r\n \"createdBy\": \"John Doe\",\r\n \"createdDateTime\": \"2021-04-27T11:04:00Z\",\r\n \"iconUrl\": \"https://contentdepot.blob.core.windows.net/filedepot/sampleIconUrl.png\",\r\n \"authors\": [\r\n \"John Doe\"\r\n ],\r\n \"authors@odata.type\": \"Collection(String)\",\r\n \"lastModifiedDate\": \"2021-04-27T11:04:00Z\",\r\n \"url\": \"https://sampleItemUrl.com\",\r\n \"containerName\": \"Sample container name\",\r\n \"containerUrl\": \"https://sampleContainerUrl.com\"\r\n },\r\n \"content\": {\r\n \"type\": \"text\",\r\n \"value\": \"Empower customers and partners to be more productive by enabling them to bring content and activity information and allow external content to participate in Microsoft Search and OfficeHub experiences so that they find relevant and actionable information across all their applications.\"\r\n }\r\n}"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/external/connections/sampleConnectionId/items/sampleItemId",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"external",
"connections",
"sampleConnectionId",
"items",
"sampleItemId"
]
}
},
"response": [
]
}