https://servernamehidden:3434/sites/hkDev/_api/web/lists/getByTitle(@doclibname)/RootFolder/folders(@folderunderl1)/files/add(url=@filnme,overwrite=@ovrt)?@doclibname='hemantSample'&@folderunderl1='hemFolder'&@filnme='hemanttestfile3.txt'&@ovrt='true'
while chunk upload, if there is no previous version at this path, create a dummy file
Params
@doclibname | 'hemantSample'
in this sample I used getByTitle to get the SPDocLib.
|
@folderunderl1 | 'hemFolder'
This is a level 1 folder inside the document library.
|
@filnme | 'hemanttestfile3.txt'
This is intended file name and url in the target folder. Input file name could be anything while extracting binary on local machine. but this filenme is unique in a folder.
|
@ovrt | 'true'
if file exist already, overrite, if version is enabled in document library, next version is created.
|
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/lists/getByTitle(@doclibname)/RootFolder/folders(@folderunderl1)/files/add(url=@filnme,overwrite=@ovrt)?@doclibname=%5C'hemantSample%5C'&@folderunderl1=%5C'hemFolder%5C'&@filnme=%5C'hemanttestfile3.txt%5C'&@ovrt=%5C'true%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'content-length': '49',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': 'application/octet-stream'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.03 Checkout (caution, you will get two versions in case of new file)
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/CheckOut()?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
Checkout an existing file OR the dummy one just created. You may want to check out a file to make sure that no one changes it before you update it. After your update, you should check the file back in so that others can work with it.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/CheckOut()?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.04 Chunk upload Start 1 send first chunk
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/startupload(uploadId=@hemsession)?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&@hemsession='6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'
start sending file stream step 1. pass binary in the body.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
@hemsession | '6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'
something like a guid to bind together startupload, continue upload (multiple may be) and finish upload.
|
Body
file
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/startupload(uploadId=@hemsession)?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&@hemsession=%5C'6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': 'application/octet-stream'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.05 Continue Upload2
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/continueupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&@hemsession='6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'&@offf=49
send second chunk step 2. pass binary in the body.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
@hemsession | '6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'
something like a guid to bind together startupload, continue upload (multiple may be) and finish upload.
|
@offf | 49
fileOffset in case of continue upload and finish upload only
|
Body
file
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/continueupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&@hemsession=%5C'6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527%5C'&@offf=49',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': 'application/octet-stream'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.06 Continue Upload3
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/continueupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&@hemsession='6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'&@offf=98
send third chunk step 3. pass binary in the body.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
@hemsession | '6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'
something like a guid to bind together startupload, continue upload (multiple may be) and finish upload.
|
@offf | 98
fileOffset in case of continue upload and finish upload only
|
Body
file
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/continueupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&@hemsession=%5C'6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527%5C'&@offf=98',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': 'application/octet-stream'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.07 Continue Upload4
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/continueupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&@hemsession='6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'&@offf=147
send forth chunk step 4, and so on till last chunk. pass binary in the body.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
@hemsession | '6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'
something like a guid to bind together startupload, continue upload (multiple may be) and finish upload.
|
@offf | 147
fileOffset in case of continue upload and finish upload only
|
Body
file
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/continueupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&@hemsession=%5C'6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527%5C'&@offf=147',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': 'application/octet-stream'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.08 Finish Upload
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/finishupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&@hemsession='6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'&@offf=196
send last chunk step 5. pass binary in the body.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
@hemsession | '6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527'
something like a guid to bind together startupload, continue upload (multiple may be) and finish upload.
|
@offf | 196
fileOffset in case of continue upload and finish upload only
|
Body
file
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/finishupload(uploadId=@hemsession, fileOffset=@offf)?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&@hemsession=%5C'6d8e4933-fd7f-4ac3-aa96-be3a0a5c9527%5C'&@offf=196',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': 'application/octet-stream'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();
POST 05.09 Send Metada data without version update 1st time after upload
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/listitemallfields/validateupdatelistitem?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
send atleast mandatory fields please, step 6. body contains JSON of formValues and bNewDocumentUpdate. bNewDocumentUpdate needs to be true to avoid ++version. checkincomments can also be passed in body if file was checkedout.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
Body
raw ( application/json;odata=verbose)
{
"formValues": [
{
"__metadata": {
"type": "SP.ListItemFormUpdateValue"
},
"FieldName": "hk1_hk2_hk3",
"FieldValue": "4_1318_896|8c843e5f-2289-4559-b5d4-8eba4ed04885;5_1319_896|384161b9-0f7d-4985-bfa2-400adf8dc3bd;1_1320_896|0e44c06a-dfac-422b-b0d4-c4f94e20f0a1;2_1321_896|fe57e512-8b13-47d2-8fd8-96f47c923a4f;"
},
{
"__metadata": {
"type": "SP.ListItemFormUpdateValue"
},
"FieldName": "hemcreator",
"FieldValue":"[{'Key': 'dummyuser1'}]"
}
,
{
"__metadata": {
"type": "SP.ListItemFormUpdateValue"
},
"FieldName": "Author",
"FieldValue":"[{'Key': 'dummyuser2'}]"
}
,
{
"__metadata": {
"type": "SP.ListItemFormUpdateValue"
},
"FieldName": "Editor",
"FieldValue":"[{'Key': 'dummyuser3'}]"
}
,
{
"__metadata": {
"type": "SP.ListItemFormUpdateValue"
},
"FieldName": "prjnme",
"FieldValue": "hk_blog"
}
],
"bNewDocumentUpdate": true
}
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/listitemallfields/validateupdatelistitem?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': ' application/json;odata=verbose'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = "{\r\n \"formValues\": [\r\n {\r\n \"__metadata\": {\r\n \"type\": \"SP.ListItemFormUpdateValue\"\r\n },\r\n \"FieldName\": \"hk1_hk2_hk3\",\r\n \"FieldValue\": \"4_1318_896|8c843e5f-2289-4559-b5d4-8eba4ed04885;5_1319_896|384161b9-0f7d-4985-bfa2-400adf8dc3bd;1_1320_896|0e44c06a-dfac-422b-b0d4-c4f94e20f0a1;2_1321_896|fe57e512-8b13-47d2-8fd8-96f47c923a4f;\"\r\n },\r\n {\r\n \"__metadata\": {\r\n \"type\": \"SP.ListItemFormUpdateValue\"\r\n }, \r\n \"FieldName\": \"hemcreator\",\r\n \"FieldValue\":\"[{'Key': 'dummyuser1'}]\"\r\n }\r\n ,\r\n {\r\n \"__metadata\": {\r\n \"type\": \"SP.ListItemFormUpdateValue\"\r\n }, \r\n \"FieldName\": \"Author\",\r\n \"FieldValue\":\"[{'Key': 'dummyuser2'}]\"\r\n }\r\n ,\r\n {\r\n \"__metadata\": {\r\n \"type\": \"SP.ListItemFormUpdateValue\"\r\n }, \r\n \"FieldName\": \"Editor\",\r\n \"FieldValue\":\"[{'Key': 'dummyuser3'}]\"\r\n }\r\n ,\r\n {\r\n \"__metadata\": {\r\n \"type\": \"SP.ListItemFormUpdateValue\"\r\n },\r\n \"FieldName\": \"prjnme\",\r\n \"FieldValue\": \"hk_blog\"\r\n }\r\n ],\r\n \r\n \"bNewDocumentUpdate\": true\r\n}";
req.write(postData);
req.end();
POST 05.10 Send modifier without version update
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/listitemallfields/validateupdatelistitem?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
if the file was checked out, this is needed - to fix
Editor ( we want to store actual editor, since we are using service account).
Reason being checkout was done by Service account, not the actual user. And
hence modifier is changed to service user
after sending metadata in the last call.
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
Body
raw ( application/json;odata=verbose)
{
"formValues": [
{
"__metadata": {
"type": "SP.ListItemFormUpdateValue"
},
"FieldName": "Editor",
"FieldValue":"[{'Key': 'dummyuser3'}]"
}
],
"bNewDocumentUpdate": true
}
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/listitemallfields/validateupdatelistitem?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000',
'Content-Type': ' application/json;odata=verbose'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = "{\r\n \"formValues\": [\r\n \r\n {\r\n \"__metadata\": {\r\n \"type\": \"SP.ListItemFormUpdateValue\"\r\n }, \r\n \"FieldName\": \"Editor\",\r\n \"FieldValue\":\"[{'Key': 'dummyuser3'}]\"\r\n }\r\n \r\n ],\r\n \r\n \"bNewDocumentUpdate\": true\r\n}";
req.write(postData);
req.end();
GET 06.01 Get File Metadata ListItemAllFields
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/ListItemAllFields?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
var https = require('https');
var options = {
'method': 'GET',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/ListItemAllFields?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
GET 06.02 Get File Metadata select specific in ListItemAllFields
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/ListItemAllFields?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&$select=Title,hk1_hk2_hk3
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
$select | Title,hk1_hk2_hk3
limit selection to two properties here.
|
var https = require('https');
var options = {
'method': 'GET',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/ListItemAllFields?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&$select=Title%2Chk1_hk2_hk3',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
GET 06.03 Get File Stream
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/$value?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
var https = require('https');
var options = {
'method': 'GET',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)/$value?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
GET 06.04 Get Previous Versions
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl('/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt')/versions?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
var https = require('https');
var options = {
'method': 'GET',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(\'/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt\')/versions?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
POST 06.05 Checkin (just in case needed)
https://servernamehidden:3434/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)//CheckIn(comment=@comm,checkintype=@typ)?@fileurl='/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'&@comm='some comments here plz'&@typ=0
The following example shows how to check in a file
Params
@fileurl | '/sites/hkDev/hemsample/hemFolder/hemanttestfile3.txt'
getfilebyserverrelativeurl needs file url like relative to the web application.
|
@comm | 'some comments here plz'
|
@typ | 0
MinorCheckIn (0) , MajorCheckIn(1) or OverwriteCheckIn(2)
|
var https = require('https');
var options = {
'method': 'POST',
'hostname': 'servernamehidden',
'path': '/sites/hkDev/_api/web/getfilebyserverrelativeurl(@fileurl)//CheckIn(comment=@comm,checkintype=@typ)?@fileurl=%5C'%2Fsites%2FhkDev%2Fhemsample%2FhemFolder%2Fhemanttestfile3.txt%5C'&@comm=%5C'some%20comments%20here%20plz%5C'&@typ=0',
'headers': {
'Accept': ' application/json;odata=verbose',
'X-RequestDigest': '0xA1XX411AXXAA0XX0X1101011AX11XX11AXXA1X11X1X114X11011AX410142X01X2131XXXX1AX23101411AX1X1X31XA3X0XX4XX131XX1141X111XX1XX1XX1110X4,03 Apr 2011 14:40:01 -0000'
}
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = ;
req.write(postData);
req.end();