I'm creating a folder inside library via rest and as next step I search it again via

/_api/web/lists/getbytitle('{docLibraryName}')/Items?$filter=(OpportunityNumber eq '{folderName}')&$top=1

to get Edit url in a form


as only this url which has List guid and numeric ID of a folder allows me to do post to update its metadata.

problem is first query returns me guid (after placing index on it) of the folder and not numeric value


Is there a way to get numeric ID of a folder by its guid, or do the whole process in less steps, note I've tried


does not work and returns 'Value does not fall within the expected range.'

  • What is OpportunityNumber column here? You want item ID for a folder? – Ganesh Sanap Apr 30 at 3:25

To create a folder and get its ID in one request, you can simply create a list item with a folder content type (0x0120):

POST request

/_api/web/lists/getByTitle('Custom List')/items


ContentTypeId: "0x0120"
Title: "FolderName"
__metadata: {type: "SP.Data.CustomListListItem"}
type: "SP.Data.TListItem"


ID: 1
Id: 1
Title: "FolderName"
odata.id: "1c6a9c3a-2598-486a-8158-cf45d0503fd6"

Returned ID is the folder's item ID.


You can use the $select parameter to select the folder ID like below:


This will return you the folder name & ID like:

<content type="application/xml">
        <d:ID m:type="Edm.Int32">33</d:ID>

You can modify your REST call something like:

/_api/web/lists/getbytitle('{docLibraryName}')/Items?$select=FileLeafRef,ID,OpportunityNumber&$filter=(OpportunityNumber eq '{folderName}')&$top=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.