2

The main idea of this is to create an item from workflow in another list which is located on different site collection. So I thought is it possible to create an item in list with REST API through the workflow?

0

Item can be created by calling REST service API from SharePoint Workflow. SharePoint Workflow provides various actions like call, build, etc.

Build action is used to call your REST service API.

Call action calls the REST service and execute the action that you have given into REST API.

Please look at this Rest call using SharePoint workflow for reference

Thanks

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • Please avoid just posting a link as an answer. Quote the main aspects of the article as well as the links tend to go down. – Paul Strupeikis Apr 25 '16 at 10:37
0

The steps below are auto-generated from a tool I created that you can add to your SharePoint site. You can test your REST API calls there, and then display the steps for AJAX or SharePoint Workflows. http://techtrainingnotes.blogspot.com/2017/04/a-sharepoint-rest-api-tester-with-ajax.html

Steps to add a new item to an Announcements list:

Add Build Dictionary Action for the header values.

Add a Build Dictionary action.

Click "this".

Click "Add", enter data and click OK for each of the following.
Name: accept
Type: String
Value: application/json;odata=verbose

Name: content-type
Type: String
Value: application/json;odata=verbose

Click OK.

Click "Variable:dictionary".

Click "Create a new variable".

Enter "requestHeaders".

Click OK.

Add a second Dictionary with these values and save to a variable named dataType.
Name: type
Type: String
Value: SP.Data.AnnouncementsListItem

Add a third Dictionary with these values and save to a variable named requestContent.
Name: __metadata
Type: Dictionary
Value: Variable: dataType (from the fx button)

Name: Title
Type: String
Value: Test announcement

Name: Body
Type: String
Value: hello!

Add Call HTTP Web Service Action.

Add a Call HTTP Web Service action.

Click "this".

Enter URL with the query string or...

Click "...".

Click "Add or Change Lookup".

From "Data Source" select "Workflow Context".

From "Field from source" select "Current Site URL". Click OK.

Add the following: (with the correct site path!)
_api/web/lists/GetByTitle('Announcements')/Items

Set the HTTP method to: HTTP POST.

Click OK.

Click the dropdown and click Properties.

Click "RequestHeaders" and select "requestHeaders" from the dropdown.

Click "RequestContent" and select "requestContent" from the dropdown.

Click "ResponseContent" and select "Create New Variable" from the dropdown, enter "responseData" and click OK.

Add a Get an Item from a Dictionary Action so you can display some results.

Add a Get an Item from a Dictionary action.

Click "item by name or path". (You will need to know the data that's being returned to complete this.) Example: Id

Click "dictionary" and select "responseData".

Click "item" and enter a variable name for your retrieved data.

Do something with your retrieved data! Log it, add to a list or send as part of an email!

  • Also remember to grant your workflow full control on tenant level if you want it to create an item on a different collection :) – Morten K Sep 18 '18 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.