Bonjour à tous,
Je tente d'ajouter des items à une liste via VBA.
J'utilise le code ci dessous que j'ai trouvé sur ce site :
Mon probleme est le suivant : CA ne fonctionne pas...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 Sub Add_Item(ListName As String, SharepointUrl As String, ValueVar As String, FieldNameVar As String) Dim objXMLHTTP As MSXML2.XMLHTTP Dim strListNameOrGuid As String Dim strBatchXml As String Dim strSoapBody As String Set objXMLHTTP = New MSXML2.XMLHTTP strListNameOrGuid = ListName 'Add New Item' strBatchXml = "<Batch OnError='Continue'><Method ID='3' Cmd='New'><Field Name='ID'>New</Field><Field Name=" + FieldNameVar + ">" + ValueVar + "</Field></Method></Batch>" objXMLHTTP.Open "POST", SharepointUrl + "_vti_bin/Lists.asmx", False objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=""UTF-8""" objXMLHTTP.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems" strSoapBody = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " _ & "xmlns:xsd='http://www.w3.org/2001/XMLSchema' " _ & "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><UpdateListItems " _ & "xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>" & strListNameOrGuid _ & "</listName><updates>" & strBatchXml & "</updates></UpdateListItems></soap:Body></soap:Envelope>" objXMLHTTP.send strSoapBody If objXMLHTTP.Status = 200 Then ' Do something with response End If Set objXMLHTTP = Nothing End Sub
En effet, si je rentre l'url du web service de cette manière : //serveur/monsite_vti_bin/Lists.asmx Le statut de la requête est "OK" mais rien ne s'affiche dans Sharepoint.
Si je rentre l'url de cette manière (ce qui devrait etre juste) : //serveur/monsite/_vti_bin/Lists.asmx La réponse est "Bad request"
Est ce que quelqu'un d'entre vous à déjà réalisé ce type d'opération ?
Par avance, merci
Partager