4

I have a sharepoint server 2016 like the one I show in the attached image.

I want, through a java code, to read the metadata of the document notes.txt, but I do not know what url endpoint to use for it.

Can someone solve my doubt?

Thank you.

My Sharepoint site

6

You can use the SharePoint REST API for files and folders to get the metadata (or content) of the file.

For your example, the server-relative endpoint URL would be:

  • The file with basic metadata:

    /my/personal/KIEWB/_api/web/getfilebyserverrelativeurl('/my/personal/KIEWB/Documentos compartidos/notas.txt')

  • The file content:

    /my/personal/KIEWB/_api/web/getfilebyserverrelativeurl('/my/personal/KIEWB/Documentos compartidos/notas.txt')/$value

  • The list item metadata for the file:

    /my/personal/KIEWB/_api/web/getfilebyserverrelativeurl('/my/personal/KIEWB/Documentos compartidos/notas.txt')/ListItemAllFields

  • ok, thank you.If I want to add metadata from an external application, should I use these endpoints as well? – Jacobo Rodríguez Feb 25 at 10:52
  • Yes. But of course you will also have to authenticate the user first before you are able to use the endpoint. – Anon Feb 25 at 11:00
  • You will need the request/form digest and it would need a two-phase approach to update the data. – vol7ron Feb 25 at 15:34
  • I can do a get of the metadata, and I can also upload a file with my code, but if I try to change the value of a metadata, it shows me a 403 error. This is part of the code: – Jacobo Rodríguez Feb 28 at 15:34
  • 1
    Try adding the header "IF-MATCH": "*". It seams to have to do with the ETag which is used to determine the sequence for and managing of concurrent updates. Providing a wildcard * will ignore the ETag. Marc Anderson (SPServices author) wrote a blog post about that. – Anon Mar 14 at 16:17

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.