2

I try to get the creation date of a Word document added to SharePoint using the REST API.

Metadata properties of my document created at 2012-03-09:

enter image description here

My URL to get document information:

http://{my-server-name}/_api/search/query?querytext='{word document}'&selectProperties='UniqueId,Title,Author,HitHighlightedSummary,IsDocument,Filename,Path,FileExtension,SecondaryFileExtension,Size,Created,CreatedOWSDATE,ModifiedOWSDATE,Write,LastModifiedTime'

Data returned:

<d:element m:type="SP.KeyValue">
    <d:Key>Created</d:Key>
    <d:Value>2016-02-02T15:22:07.0000000Z</d:Value>
    <d:ValueType>Edm.DateTime</d:ValueType>
</d:element>
<d:element m:type="SP.KeyValue">
    <d:Key>CreatedOWSDATE</d:Key>
    <d:Value>2016-02-02T15:22:07Z</d:Value>
    <d:ValueType>Edm.String</d:ValueType>
</d:element>
<d:element m:type="SP.KeyValue">
    <d:Key>ModifiedOWSDATE</d:Key>
    <d:Value>2016-02-04T20:10:54Z</d:Value>
    <d:ValueType>Edm.String</d:ValueType>
</d:element>
<d:element m:type="SP.KeyValue">
    <d:Key>Write</d:Key>
    <d:Value>2015-06-02T15:21:00.0000000Z</d:Value>
    <d:ValueType>Edm.DateTime</d:ValueType>
</d:element>
<d:element m:type="SP.KeyValue">
    <d:Key>LastModifiedTime</d:Key>
    <d:Value>2015-06-02T15:21:00.0000000Z</d:Value>
    <d:ValueType>Edm.DateTime</d:ValueType>
</d:element>

I can't find the real creation date set in the Word metadata.

  • The REST API isn't going to give you the Word metadata, it is only going to pull the Created by date of the document list item. – Eric Alexander Feb 4 '16 at 21:12
  • Hmm I tought that the search would used the Word metadata, because I can get the LastModifiedTime. Maybe the LastModifiedTime come from the file itself. – Jonathan Anctil Feb 4 '16 at 21:22
  • Just some wild speculation, but you might be able to get the Word metadata into SharePoint in a usable way by creating a new managed property that maps to the Word metadata. Maybe? I know there are some "Office" field options when you are setting up managed properties. – Dylan Cristy Feb 4 '16 at 21:23
  • Did you upload the file to SharePoint on 2016-02-02T15:22:07Z? Or possibly try it with a newly created document and seeing the results. It could be that migrated data won't work properly unless you use script to update the created date to the actual value. – Eric Alexander Feb 4 '16 at 21:24
  • 1
    Right, well that one is the usual "Created" date, but as you can see, it maps to more than one piece of metadata, so it might be set up to "prefer" the SharePoint metadata over the Office metadata. If you can figure out which one of those really maps to the Word document metadata, you can set up a new managed property that maps only to that. Then maybe you can access it that way. Search around for how to set up custom managed properties and you will start to see how it works. – Dylan Cristy Feb 4 '16 at 21:41
1

Thanks to @DylanCristy for the hint.

To solve my problem, I've added «CreateDateTime» to the mapping of the «Created» property:

enter image description here

I reset the index, run a full crawl and it works!

<d:element m:type="SP.KeyValue">
    <d:Key>Created</d:Key>
    <d:Value>2012-03-09T19:30:00.0000000Z</d:Value>
    <d:ValueType>Edm.DateTime</d:ValueType>
</d:element>
  • 1
    Glad that it works, but be careful with that. You've now just changed the way the default "Created" field works. You might end up with some strange results elsewhere. That's why I was suggesting creating a new managed property... – Dylan Cristy Feb 4 '16 at 22:03
  • Yeah you're right, I will discuss with the FA and will create a new managed property. – Jonathan Anctil Feb 4 '16 at 22:05

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.