「東雲 忠太郎」の平凡な日常のできごと

「東雲 忠太郎」の平凡な日常のできごと

2024.02.26
XML
カテゴリ: VB.NET


Imports System.Net.Http

Imports System.Text

Imports System.Threading.Tasks

Imports Newtonsoft.Json.Linq


Module Module1


    Sub Main()

        Dim siteUrl As String = "https://your-sharepoint-site-url"

        Dim username As String = "your-username"

        Dim password As String = "your-password"

        Dim listName As String = "YourListName"

        Dim createdDate As String = "2024-02-26T00:00:00Z" ' 抽出したい作成日


        GetItemsByCreatedDate(siteUrl, username, password, listName, createdDate).Wait()

    End Sub


    Async Function GetItemsByCreatedDate(siteUrl As String, username As String, password As String, listName As String, createdDate As String) As Task

        Dim credentials As String = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))


        Using client As New HttpClient()

            client.DefaultRequestHeaders.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials)


            Dim endpointUrl As String = $"{siteUrl}/_api/web/lists/getbytitle('{listName}')/items?$filter=Created eq datetime'{createdDate}'"


            Dim response As HttpResponseMessage = Await client.GetAsync(endpointUrl)


            If response.IsSuccessStatusCode Then

                Dim responseContent As String = Await response.Content.ReadAsStringAsync()

                Dim json As JObject = JObject.Parse(responseContent)

                Dim items As JArray = json("value")


                ' リストアイテムのデータを出力

                For Each item As JObject In items

                    Console.WriteLine($"ID: {item("Id")}, Title: {item("Title")}, Created: {item("Created")}")

                Next

            Else

                Console.WriteLine($"Failed to retrieve list items. StatusCode: {response.StatusCode}")

            End If

        End Using

    End Function

End Module







お気に入りの記事を「いいね!」で応援しよう

Last updated  2024.02.26 02:55:01


【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! -- / --
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x

© Rakuten Group, Inc.
Create a Mobile Website
スマートフォン版を閲覧 | PC版を閲覧
Share by: