Skip to Content
Author's profile photo Dilip Kumar Krishnadev Pandey

Insert items in SharePoint using SAP-PI UDF


Here, we will see, that, how SharePoint’s AlertCount list can be updated from SAP-PI UDF.

To update AlertCount list inside SharePoint, following SharePoint-REST protocols can be used:

  • URL: https://<org_Shp_Host>/teams/SPdev/AlertsCount/_api/web/Lists/GetByTitle(‘AlertCount’)/Items
  • Method: POST
  • Headers:
    • Authorization  : “Bearer ” + <SharePointAccessToken>
      accept            : application/json;odata=verbose
      Content-Type : “application/json;odata=verbose”
  • Body: (Request Parameter format)
    • {__metadata: { ‘type’: ‘SP.Data.AlertCountListItem’ },
      Col1 : ”,
      Col2 : ”
  • where,
    • <org_Shp_Host> is Organisation’s SharePoint host name
    • Col1 is 1st column of AlertCountList
    • Col2 is 2nd column of AlertCountList
    • <SharePointAccessToken>: it is security token required to authenticate SharePoint REST request while inserting items, this token can be fetched from following blog’s udf:

SAP PI Java UDF example to insert AlertCount list items in SharePoint:

public String writeAlertCount(String accessToken, String InputCol1, String InputCol2, Container container) throws StreamTransformationException{		
		 * Using this function, we can update AlertCountList items of SharePoint.	
		 * Suppose, if we want to insert data into two columnItems ('Col1' & 'Col2') of AlertCountList in SharePoint, then following SharePoint-REST will be consumed inside this UDF
		 * REST URL: https://<org_Shp_Host>/teams/SPdev/AlertsCount/_api/web/Lists/GetByTitle('AlertCount')/Items
		 * Request Format:
		 * 			 {__metadata: { 'type': 'SP.Data.AlertCountListItem' }, Col1: 'E01', Col1: '1562' }		 * 
		 * Where, 
		 * 		<org_Shp_Host> is Organisation's SharePoint host name 
		String response = "";
		try {

			//SharePoint REST url to update AlertCount Item List
			String wsURL = "https://<org_Shp_Host>/teams/SPdev/AlertsCount/_api/web/Lists/GetByTitle('AlertCount')/Items";

			// Create Http Connection
			URL url = new URL(wsURL);
			URLConnection connection = url.openConnection();
			HttpURLConnection httpConn = (HttpURLConnection) connection;

			// Set Header
			httpConn.setRequestProperty("Authorization", "Bearer " + accessToken);
			httpConn.setRequestProperty("content-Type",	"application/json;odata=verbose");
			// Set Request parameters
			String requestP = "{__metadata: { 'type': 'SP.Data.AlertCountListItem' }, "
							+ "Col1: '"	+ InputCol1  +"', "
							+ "Col2: '"	+ InputCol2+"' }";

			// Send Request
			DataOutputStream wr = new DataOutputStream(httpConn.getOutputStream());

			//Read the response		
			if (httpConn.getResponseCode() == 200) {
				response = "Http Response Code: " + httpConn.getResponseCode();
			}else if (httpConn.getResponseCode() == 201) {
				// when HttpResponseCode is 201, this insert is successful in SharePoint.
				response = "Http Response Code: " + httpConn.getResponseCode() + "\n Item inserted successfully in sharepoint";
				response = "Error with Http Response Code: " + httpConn.getResponseCode();

		} catch (Exception e) {
			response = "Error: " + e.getMessage();
		return response;


  • UDF Run inside Graphical Map:
  • Results in SharePoint



<<<<< Parent blog reference…..  Integrate SharePoint using SAP PI

Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Many option are available and most of new features included in this awesome online support where you can get connect easily Guys I can suggest you just visit it and know you could manage of your best option file explorer.

      Author's profile photo hannah tims
      hannah tims

      A vegetarian grill evening with friends or family can also be done completely without meat.

      Author's profile photo hannah tims
      hannah tims

      Great post! This was very helpful! monster legends breeding guide Thank you so much for this!