Latest Posts

REST-API POST call using SharePoint designer workflow

In this article, we will understand how to create a list item in the SharePoint designer workflow using REST-API POST method. Designer workflows are a very essential part of most of the SharePoint development projects. Let’s see how we can use REST-API POST method in the designer workflow.

The step-by-step process of creating a designer workflow using REST-API POST method

You can check how to create a list item using REST-API programmatically. The same example we have utilized for reference in this article.

  1. Open SharePoint Designer. Here, we have shown List workflow. Click on List Workflow from Ribbon and add workflow details. Make sure you select latest platform Type – SharePoint 2013 Workflow
  2. create sharepoint 2013 workflow
  3. We need to create a total of three dictionary variables.
  4. In Stage 1, click on Action from Ribbon and then from dropdown select, Build Dictionary.
  5. add action build dictionary
  6. We are going to create a variable of Type Dictionary and save REST call headers in it. As shown in the screenshot below, click on the ellipsis (…) to build dictionary variable values and add headers.
  7. Name

    Type

    Value

    Accept

    String

    application/json;odata=verbose

    Content-Type

    String

    application/json;odata=verbose

    dictionary values
  8. We will create one more dictionary to store the “type” value.
    NOTE:

    The format of the "type" is: SP.Data.<<ListName>>ListItem

  9. Here, the list name is List Name. You need to set the dictionary value according to your list name.

    The dictionary value will be as mentioned below.

    Name

    Type

    Value

    type

    String

    SP.Data.List_x0020_NameListItem

  10. We need to create one more dictionary for the Request Content for the POST call. Along with __metadata, you can add the columns that you have in your REST call.
  11. NOTE:
    • All the column names are internal names of the columns.
    • metadata has got two underscores (_) before it.

    Name

    Type

    Value

    __metadata

    dictionary

    The dictionary variable created in the above step

    Title (Column Internal Name)

    String

    New Title (value for the column)

    Description

    String

    New Description

  12. Next, we will add Call HTTP Web Service action.
  13. add action call http web service
  14. Select the web service action and then click on the Advanced Properties from Ribbon Menu.
  15. advanced properties navigation
  16. Now, we will add a few values which are very essential. Here, you are constructing the actual request. Mainly we have added below three parameters.
    • Address: This is the REST API URL value. You can construct it according to your requirements.
    • RequestType: Here we have used the HTTP POST method as we are creating a list item
    • RequestHeaders: This is the headers of the REST call we will assign dictionary value that we created in the first step (HeaderDictionary)
    • RequestContent: It contains the dictionary variable for new item metadata, created in the last dictionary variable above.
    • ResponseContent: This is a variable of the type Dictionary that holds the data returning by the REST call.
    • ResponseStatusCode: This is not mandatory but just kept to check the status of the REST call
    http web service values
  17. Set Transition to stage add Go to End of Workflow
  18. end of workflow
  19. Now you can publish this workflow.
  20. Go to your list and manually start the flow (you can set the trigger of the flow according to your requirement).
  21. You will notice, a list item is created.
  22. rest call item added

You can check some REST-API examples and create a designer workflow with their reference.

Conclusion:

We have gone through the steps to create a designer workflow and how to create REST - POST request using that.


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint