[SOLVED]Add List item to Sharepoint List: Data at the root level is invalid. Line 1, position 1.

Hi everyone

I have made a consumer Web service that connects to my Sharepoint site. The service works fine because when I test the connection with the method ‘GetListItems’ it shows all the items in that list.

But when I try to add an item to that list the error in the subject is shown.

Here’s the pipeline the service gives me:

For the variables tns:listName, user, pass and _port I filled in the same data as I did with ‘GetListItems’ so those should be correct.

For *body I filled in the XML below:

<Batch OnError="Continue" ListVersion="1">
	<Method ID="1" Cmd="New">
		<Field Name="Title">SAG BPMS</Field>
		<Field Name="Description">Book</Field>
		<Field Name="Email">emans@test.be</Field>
		<Field Name="Storage_x0020_Location">Kast 3</Field>
		<Field Name="Position_x0020_in_x0020_Storage">Schap 5</Field>
		<Field Name="Course_x0020_Date">2014-03-23T00:00:00+0:00</Field>
		<Field Name="Person">-1;#Emans Kevin</Field>

This code worked fine in SoapUI so I don’t know what causes the error I’m getting to be thrown.

Hopefully that’s enough information, if not, please don’t hesitate to ask.

With kind regards

Apparently the XML created with the data provided isn’t correct.

Now I have typed the entire XML as it should be, converted it to a node and then a document and, mapped that document to tns:updateListItems. Now everything works as it should.

Hardcoded XML:

<tns:UpdateListItems xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/">
		<Batch OnError="Continue" ListVersion="1">
			<Method ID="1" Cmd="New">
				<Field Name="Title">SAG BPMS DEV</Field>
				<Field Name="Description">Book</Field>
				<Field Name="Email">test@test.be</Field>
				<Field Name="Storage_x0020_Location">Kast 1</Field>
				<Field Name="Position_x0020_in_x0020_Storage">Schap 1</Field>
				<Field Name="Course_x0020_Date">2014-03-22T00:00:00+0:00</Field>
				<Field Name="Person">-1;#Emans Kevin</Field>

You could have
used documentToXMLString by passing empty values to tns:updateListItems - Here you will have the required xml instead of manually framing it !!!?

im getting the same issue. imported the wsdl and trying to run the webservice connector. webservice is using pub.client:soapClient.

Can anyone let me know why its not working in connector and what should be done before passing data to connector?

passing below similar data in the lsit:updates

SAG BPMS Book emans@test.be Kast 3 Schap 5 2014-03-23T00:00:00+0:00 -1;#Emans Kevin

ListName: CRM Test

Error reported as Data at the root level is invalid. Line 1, position 1.

working fine.

i formed the wm document structure like below and mapped to top level tns:updates document instead of mapping xml string to *body which was cause of the issue.


Kast 1
Schap 1
-1;#Emans Kevin