简体   繁体   中英

How to properly upload .aspx page to SharePoint using Python

I'm able to upload an Aspx page to my SharePoint project with the help of Python. The project has an "Edit" button for every Aspx page created in SharePoint which helps in editing the content of the page.

But the uploaded page from Python does not have any action for the "Edit" button. I want to know why is this happening. I'm new to Python and SharePoint automation please help me out.

Code to upload Aspx page:

path = "local path to my .aspx"

with open(path, 'rb') as content_file:
  file_content = content_file.read()
target_folder = ctx.web.get_folder_by_server_relative_url(My_SharePoint_Folder_Path)
name = os.path.basename(path)
target_file = target_folder.upload_file(name, file_content).execute_query()
print("File has been uploaded to url: {0}".format(target_file.serverRelativeUrl))

This is the button that I'm talking about: Edit Button

Am I doing something wrong or do I have to change settings. Please help!!

Problem related to content types of files you try to upload, files with ContentType of Site Page can edit by SharePoint

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM