samedi 10 janvier 2015

SharePoint Add List Attachment Programmatically 404

I'm not having much luck with this...



[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$lists_pxy = New-WebServiceProxy -Uri 'https://myserver/_vti_bin/Lists.asmx?WSDL' -UseDefaultCredential

$list = $lists_pxy.GetList('Test Me')

$list_and_view = $lists_pxy.GetListAndView('Test Me', '')
$view_id = $list_and_view.childnodes.item(1).name

$xdoc = [xml] (@'
<Batch OnError="Continue" ListVersion="1" ViewName="{0}">
<Method ID="1" Cmd="New">
<Field Name="Title">Test Title</Field>
</Method>
</Batch>
'@ -f $view_id)

$result = $lists_pxy.UpdateListItems('Test Me', $xdoc.Batch)

$list_item_id = $result.SelectNodes('//@ows_ID') | select -exp '#text'
$bytes = [IO.File]::ReadAllBytes("D:\my.file")
$lists_pxy.AddAttachment($list.Name, $list_item_id, "my.file", $bytes)


Every time I call AddAttachment I get a 404 error...



Exception calling "AddAttachment" with "4" argument(s): "The request failed with HTTP status 404: Not Found."


Any ideas?


Aucun commentaire:

Enregistrer un commentaire