Four Stars

How to update REST API (sharepoint) list items

Hi,

I am using Talend Big data platform version 6.3 and trying to update REST API (Sharepoint) list items using tRESTClient through POST method and XML content, but it's not working out. Not sure if this is occurring due to improper configuration of tRESTClient component.

 

Could anyone please help on the same and let me know if it can be feasible through tRESTClient. If not, please suggest some other components.

 

Thanks in advance!!

 

Regards,

Pragya

1 ACCEPTED SOLUTION

Accepted Solutions
Six Stars

Re: How to update REST API (sharepoint) list items

Try removing the first line entirely

<?xml version=\"1.0\" encoding=\"utf-8\"?>

It also looks like you need a space between Envelope and xmlns on the second line.

If you're still getting errors, it may be due to a single or double quote in the message.

What I typically do for something like this, is put every variable (in your example: the 15 for 'ID' and the Y for 'File Processed Flag') into a globalMap variable, or a tJavaRow variable + just insert that into the SOAP body.

In the following code, you would have to set the values of the 2 global variables (id and fileProcessFlag) before this component, using a tSetGlobalVar component.

 

"
<soap:Envelopexmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance 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>Customer File Uploads</listName>
     <updates>
      <Batch OnError='Continue' ListVersion='1'>
       <Method ID=\"1\" Cmd=\"Update\">
        <Field Name='ID'>"+(String)globalMap.get("id")+"</Field>
        <Field Name='File Processed Flag'>"+(String)globalMap.get("fileProcessFlag")+"</Field>
       </Method>
     </Batch>
    </updates>
  </UpdateListItems>
 </soap:Body>
</soap:Envelope>
"

If you still have errors, the only other thing I can think of is the list name containing white space. You may need to surround it with single or escaped double quote. It is definitely a formatting issue.

5 REPLIES
Six Stars

Re: How to update REST API (sharepoint) list items

Are you working with a sharepoint list?

If so, sharepoint requires you to include the parameters of the update in the HTTP body for any list item updates -> see the section on updating a list item.

In this case, use the tRest component .  Otherwise you can use the sharepoint SOAP 'UpdateList' operation using tSoap component.

Four Stars

Re: How to update REST API (sharepoint) list items

Thank you for the response !!!

 

I am trying to use tSOAP component to update the Sharepoint list items and have entered the proper endpoint and SOAP action details. Below is my SOAP message. But I'm getting some Bad request error while executing the job. do you have any idea if there is any issue with the SOAP message below.

 

SOAP message:

"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelopexmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance\"
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>Customer File Uploads</listName>
<updates>
<Batch OnError='Continue' ListVersion='1'>
<Method ID=\"1\" Cmd=\"Update\">
<Field Name='ID'>15</Field>
<Field Name='File Processed Flag'>Y</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
</soap:Body>
</soap:Envelope>"

 

Error description: 

 

com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; Bad Request
Exception in component tSOAP_1

 

Regards,

Pragya

Six Stars

Re: How to update REST API (sharepoint) list items

Try removing the first line entirely

<?xml version=\"1.0\" encoding=\"utf-8\"?>

It also looks like you need a space between Envelope and xmlns on the second line.

If you're still getting errors, it may be due to a single or double quote in the message.

What I typically do for something like this, is put every variable (in your example: the 15 for 'ID' and the Y for 'File Processed Flag') into a globalMap variable, or a tJavaRow variable + just insert that into the SOAP body.

In the following code, you would have to set the values of the 2 global variables (id and fileProcessFlag) before this component, using a tSetGlobalVar component.

 

"
<soap:Envelopexmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance 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>Customer File Uploads</listName>
     <updates>
      <Batch OnError='Continue' ListVersion='1'>
       <Method ID=\"1\" Cmd=\"Update\">
        <Field Name='ID'>"+(String)globalMap.get("id")+"</Field>
        <Field Name='File Processed Flag'>"+(String)globalMap.get("fileProcessFlag")+"</Field>
       </Method>
     </Batch>
    </updates>
  </UpdateListItems>
 </soap:Body>
</soap:Envelope>
"

If you still have errors, the only other thing I can think of is the list name containing white space. You may need to surround it with single or escaped double quote. It is definitely a formatting issue.

Four Stars

Re: How to update REST API (sharepoint) list items

Code is working fine now. However it's not updating anything in Sharepoint List.

 

 

Four Stars

Re: How to update REST API (sharepoint) list items

Thank you so much @evansdar

 

My code is working fine now. I was making small mistake while passing ItemId (It need not be written in quotes, as it's numeric).

 

Really appreciate your help on this!!.

 

Regards,

Pragya