0

below is the code..

Add-Type -Path "D:\dll\Microsoft.SharePoint.Client.dll"
Add-Type -Path "D:\dll\Microsoft.SharePoint.Client.Runtime.dll"
$plainpassword = "xxx"
$Securepassword = $plainpassword | ConvertTo-SecureString -AsPlainText -Force
$ctx = New-Object System.Net.WebClient 
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://xxx.xxx.xxx")
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("xxx" , $Securepassword)
$ctx.Credentials = $credentials
$web = $ctx.Web
$ctx.Load($web)
$siteUrl = "https://xxx/source"
Try
{
$ctx.ExecuteQuery()
Write-Host "Connected to SharePoint Online site: '$siteUrl'" -ForeGroundColor Green
}
Catch
{
Write-Host "Unable to Connectt to O365 , Please try again with the valid inputs(username, pasword,siteUrl) " -ForeGroundColor Red
$ctx.Dispose()
}

$id = New-Object System.Guid("7d9931f9-1af8-421f-82f8-e4c3ee45b23c") 
$client = New-WebServiceProxy("https://dxx.xxx.xxx/SitePages/Home.aspx/_vti_bin/Webpartpages.asmx")
$client.Url = ("https://xxx.xxx.xxx/SitePages/Home.aspx/_vti_bin/Webpartpages.asmx")
$client.Credentials = $credentials
$methods=$client.Events
Write-Host "$methods"
#webPartId is a property of WebPart Defenition from the above code
$webPartXmlString = $client.GetWebPart2("https://xxx.xxx.xxx/SitePages/Home.aspx",$id,"Shared","Version3")

it results in:

Exception calling "GetWebPart2" with "4" argument(s): "The request failed with an empty response." At line:30 char:1 + $webPartXmlString = $client.GetWebPart2("https://digitalcoe.sharepoin ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WebException

  • 1
    Can you please describe what your code is trying to do? – Asad Refai Nov 30 '15 at 9:16
  • I am trying to get the webpart xml from the SharePoint page. – user48508 Nov 30 '15 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.