全て
| カテゴリ未分類
| 通常
| 数学
| 投資
| 副業
| 転職・就職
| ブログ
| 株Stock
| VBA
| SharePoint
| REST API
| RenderListDataAsStream
| PowerAutomateDesktop
| Graph API
| PowerApps
| PowerAutomate
| PowerFx
| OfficeScriptオフィススクリプト
| PowerAutomate日時Excel日時相互関係
| PowerShell
| Dataverse
| UiPath
| OneDrive
| LINQ
| VB.NET
| C#.NET
| WPFC#.NET
| Git
カテゴリ:REST API
import requests # SharePoint サイト URL site_url = "https://your-sharepoint-site" # リスト名 list_name = "YourListName" # SharePoint サイトへのリクエストを送信するためのユーザー名とパスワード username = "your_username" password = "your_password" # リストに追加するデータ new_item_data = { 'Title': 'New Item Title', 'Description': 'Description of the new item' } # 追加するアイテムのエンドポイント URL endpoint_url = f"{site_url}/_api/web/lists/getbytitle('{list_name}')/items" # 認証情報を含むセッションを作成 session = requests.Session() session.auth = (username, password) # アイテムをリストに追加するためのリクエストボディ request_body = { '__metadata': {'type': 'SP.Data.' + list_name + 'ListItem'} } request_body.update(new_item_data) # SharePoint にデータを追加 response = session.post(endpoint_url, json=request_body, headers={'Accept': 'application/json;odata=verbose', 'Content-Type': 'application/json;odata=verbose'}) # 応答の解析 if response.status_code == 201: print("Item added successfully.") else: print("Failed to add item to SharePoint. Status code:", response.status_code) お気に入りの記事を「いいね!」で応援しよう
Last updated
2024.02.27 07:16:08
[REST API] カテゴリの最新記事
|