Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Offen: Sharepoint upload File Error

21.11.2019 (👁231)

Offen: Sharepoint upload File Error

Error: Error making HttpClient request in queryable [400] Bad Request ::> {"odata.error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"de-DE","value":"Server relative urls must start with SPWeb.ServerRelativeUrl"}}}

Upload Script in Client für Webpart

VS Code

    private _UploadClicked(_evt) {

        UploadDocument.Me.setState({ waitHidden: false });

        sp.setup({ spfxContext: UploadDocument.Me.props.controller.context });

        var listId = UploadDocument.Me.props.controller.QueryStringParameter("listid");

        var processId = UploadDocument.Me.props.controller.QueryStringParameter("pid");

        var filesHTMLInputElement = document.getElementById("fileUpload"as HTMLInputElement;

        var listNamestring;

        UploadDocument.Me.props.controller.GetListNameById(Guid.parse(listId)).then(list => {

            listName = list.Title;

            var file = files.files[0];

            UploadDocument.Me.props.controller.HasListRight(Permissions.addListItemsGuid.parse(listId)).then(r => {

                if (r) {

                    console.log("Benutzer hat Rechte Files hinzuzufügen");

                }

                else {

                    console.log("Benutzer hat keine Rechte Files hinzuzufügen");

                }

            });

            console.log("Listname: " + listName);

            //Upload a file to the SharePoint Library

            UploadDocument.Me.props.controller.GetRootFolderById(Guid.parse(listId)).then(fld => {

                var folderId = fld.UniqueId;

                console.log("FolderId: " + folderId);

                var folderRelativUrl = fld.ServerRelativeUrl;

                console.log("FolderRelativUrl: " + folderRelativUrl);

                var folderFolder = sp.web.getFolderById(Guid.parse(folderId).toString());

                console.log(sp.web.rootFolder.toUrl);

                sp.web.getFolderByServerRelativeUrl(folderRelativUrl).files.add(file.name, file, true).then(x => {

                    console.log("Progress ...");

                    UploadDocument.Me.setState({ waitHidden: true });

                });

                //console.log("FolderUrl: " + folder.Name);

                console.log("Filename: " + file.name);