0

i am trying to update a file properties that i have just uploaded. Once the file has been added to the library,i am doing another http request to get the file properties but it is not working.i can't seem to get any fields return. Here my code :

let web:Web=new Web(_context.pageContext.web.absoluteUrl);  
    var listItem=web.lists.getById(_listName).rootFolder.files.getByName(file.name).listItemAllFields
    console.log(listItem);

I am using this spfx sample: link

The code for the upload of files can be found here: https://github.com/SharePoint/sp-dev-fx-webparts/blob/master/samples/react-file-upload/src/webparts/fileUpload/components/FileUpload.tsx

Code for upload using dropzone component:

 processing: function (file, xhr) {

    if(_fileUploadTo=="DocumentLibrary")
      myDropzone.options.url = `${_context.pageContext.web.absoluteUrl}/_api/web/Lists/getById('${_parent.props.listName}')/rootfolder/files/add(overwrite=true,url='${file.name}')`;          


      else
    {          

        alert('Item not found or query string value is null!')
    }
  },

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.