I am trying to update the CheckoutUser for a file in SharePoint because when the file is checked out in my code, it is being checked out by a SharePoint admin account and I want the CheckoutUser to show the person who actually checked it out. Whenever I make a request to _api/web/GetList(#path)/items(id)/ValidateUpdateListItem()?#path='/url' with the user info, I get a 200 response back and no errors, but for some reason the CheckoutUser value is cleared instead up updating to be the user that I want to set. This is what the request body looks like:
{
"formValues": [
{
"FieldName": "CheckoutUser",
"FieldValue": "[{'Key': 'i:0#.w|user.name'}]"
}
],
"bNewDocumentUpdate": true
}
I have tested out requests to both SharePoint 2016 and SharePoint Online using Postman and have not been able to get the CheckoutUser to update in either case.
Related
I could use some help deleting a folder using the Microsoft Graph API. The api call below works, but only when the folder is empty and has no children.
DELETE https://graph.microsoft.com/v1.0/drives/{{driveId}}/items/{{driveItemId}}
The folders are created and deleted using the same client application and permissions
It's a folder in a Sharepoint document library if that matters at all
I tried adding an If-Match header with the current eTag of the folder, but that didn't make any difference.
Here's the response I'm getting:
409 Conflict
{
"error": {
"code": "resourceModified",
"message": "The resource has changed since the caller last read it; usually an eTag mismatch",
"innerError": {
"date": "2022-10-17T21:40:30",
"request-id": "b3d35695-...",
"client-request-id": "b3d35695-..."
}
}
}
Is there a way to force the delete, or do I have to clear it out before I can delete it? If I have to clear it out, what's the easiest way to do that?
I tried to reproduce the same in my environment and got below results:
I have one Azure AD application and granted API permissions like below:
To call Microsoft Graph, I acquired access token using client credentials flow via Postman as below:
I created folder in my SharePoint document library using above token with below query:
POST https://graph.microsoft.com/v1.0/drives/<driveID>/items/
{
"name": "Sri Folder",
"folder": { },
}
Response:
When I checked in SharePoint Online, folder created successfully in document library like below:
Now I added children to the created folder by uploading one file to it with below query:
PUT https://graph.microsoft.com/v1.0/drives/<driveID>/items/<driveItemId>:/test.txt:/content
Response:
When I checked the same in SharePoint Online, file is uploaded to the folder successfully like below:
Now, I used the same query as you to delete the folder with children by adding If-match header and got same error like below:
DELETE https://graph.microsoft.com/v1.0/drives/<driveId>/items/<driveItemId>
If-match : etag_value
Response
To resolve the error, you need to replace If-match header with eTag.
I tried the same query by replacing If-match header with eTag, it returned Status: 204 No Content like below:
Response:
When I refreshed the page in SharePoint Online, got this error as folder got deleted along with its children:
I checked opening document library and cannot find the folder as it got deleted successfully:
I have done changes related to permissions level like created permission, updated permission in my SharePoint site, but when I am trying to get the changes via REST API through this query in Postman https://site_url/_api/site/getChanges?query={ '__metadata': { 'type': 'SP.ChangeQuery' }, 'Item':true, 'Add':true, 'Update':true, 'RoleAssignmentAdd':true, 'RoleDefinitionAdd':true, 'RoleDefinitionUpdate':true, "ChangeTokenStart": {'__metadata':{'type':'SP.ChangeToken'}, 'StringValue':'1;1;6e139bba-0c8d-4eee-bdbd-d3c5dae7fd72;637967436403100000;246144216'},"ChangeTokenEnd": null } } not able to get the changes related to the above mentioned changeType enumeration. SP.ChangeType enumeration | Microsoft Docs
For a project, I need to get some public pages' posts.
I have 105 pages I need to get posts from and my program works fine with the most of them, but not with one.
When I use my app's access token it gets me what I want, except when trying to get posts from one page, "Yaakov.Perry".
When I send a request to this page, the server sends me this error:
"error": {
"message": "Unsupported get request. Object with ID 'Yaakov.Perry' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
Also, while my app's access token works for every page except this, the access code that the graph api explorer generates works for every one (including it).
Does any one know why this problem happens and how to fix it?
My code calls the OneNote API to resolve a SharePoint Online site URL to a SiteCollectionId and SiteId. We get a bearer token, set the HTTP auth header and issue a GET request to:
https://www.onenote.com/api/v1.0/myorganization/sitecollections/FromUrl(url='https://mytenantxyz.sharepoint.com/sites/copynotesite')
For approx a week, it has been returning the expected response, similar to:
{
"#odata.context": "https://www.onenote.com:576/api/v1.0/$metadata#Microsoft.OneNote.Api.SiteMetadata",
"siteCollectionId": "111e03ac-468c-4a28-9aab-543098ef49bb",
"siteId": "555d72a0-f82f-4e4c-ae8a-17ef0ea04f32"
}
However, today it has decided to return the following in approx 9 out of 10 requests:
{
error": {
"code" : “20158”,
"message": "Unable to get SiteMetadta for the url specified in the request.",
"#api.url": "http://aka.ms/onenote-errors#C20158"
}
}
The Microsoft docs (link) explain error 20158 as:
"Unable to get metadata for the site URL specified in the request. Check the format of the supplied URL. Supported formats include https://domain.sharepoint.com/site-a and https://domain.com/sites/site-a. (SharePoint support is in Preview.)"
I was unaware that this was in preview any more (I thought it was GA), but anyway it doesn't explain why it intermittently works for exactly the same input (same URL and bearer token).
Could it just be a bug in the OneNote API or SharePoint API that it must call under the covers?
Please refer to the blog - http://blogs.msdn.com/b/onenotedev/archive/2015/06/11/and-sharepoint-makes-three.aspx
We added the FromUrl method so you can pass in an absolute site URL and get the site collection and site IDs. You should make this call only when needed, and then store the values (site collection and site IDs) for future use in your requests to the OneNote API.
this however does not answer intermittency. Please share the X-correlationId header with us for a failing request so that we can help further.
i'm using the Box View API to convert a PDF file to HTML, i'm using the /documents/{id}/content.{extension} section.
The response for this GET call is a .zip file, however i don't know how to retrive it and make downloadable.
Also note that i'm using node.js.
Thanks for your help
You can set your own webhook URL that will be called by Box when your document status changes (one POST on your webhook for "document.viewable", and one for "document.done" plus one "document.error" if an transformation error occured).
Just listen to the "document.done" status and download the assets then. Format that is posted to the webhook you have set looks like :
[{
"type": "document.done",
"data": {
"id": "4cca28f1159c4f368193d5014fabc16e"
},
"triggered_at": "2014-01-30T20:33:04.798Z"
}]
Beware of the docs and check the format programatically. Their API docs are often no quite correct and they post multiple webhooks at the time i'm writing (which is a bug i've reported).
For more info and Box View API docs