0

I have a list called Project Log on a sub-site which need to automatically copy any item created in it to another List on the parent site called Master Project Log. This has to be accomplished using the reproducible 2013 workflows.

So far, my workflow looks like the following:

RequestHeader:

  • accept - string - application/json; odata=verbose
  • content-type - string - application/json; odata=verbose
  • content-length - string - 255

Call REST API:

POST https://[domain]/sites/T3W-PM/_api/contextinfo log to ResponseContent

Get d/GetContextWebInformation/FormDigestValue from ResponseContent (output to DigestID)

Running the workflow at this point completes successfully and returns the contents of DigestID which looks like this:

0xFB1B72F8971917CCCB3E605B397CC27ACB758650ACDB98A0848D1BC8CF5A861BD33A0EC0CF094F5D1C3188D842E470A46D25F6CA9780277A74C9AFCEB471423C,12 Aug 2019 09:55:53 -0000

This should be the FormDigestValue. I then pass that into the RequestHeader and run a second REST call to create the new list item:

RequestHeader:

  • accept - string - application/json; odata=verbose
  • content-type - string - application/json; odata=verbose
  • X-RequestDigest - string - [workflow variable: DigestID]

metadata:

  • type - string - SP.Data.ListItem

RequestContent:

  • __metadata - dictionary - <workflow variable: metadata>
  • Title - string - <current project number>

Call REST API:

POST https://[domain]/sites/T3WPM/_api/web/Lists/getbytitle('[target list]')/items

The second REST call results in a BadRequest error in the workflow log. When I run the same parameters though Fiddler I get a 403 Forbidden error.

This should not happen as the account the workflow is running under is both an Owner with Full Control permissions and a Site Collection Administrator.

Can anyone spot what I'm doing wrong?

In researching this I've seen some references to OAuth authorization but I don't know how to get the OAuth authentication token or if I actually need one.

  • Have you tried using App step in workflow? – Ganesh Sanap Aug 12 at 11:09
  • I haven't but it shouldn't be necessary. Without the app step the workflow uses the initiator's permissions and the account it's running under is a Site Collection Administrator and in the Site Owners group. The lowest privileges that anyone accessing this site will have is Contribute which is more than enough to create new list items. – JonS Aug 12 at 12:00
0

The type for creating a new list item is not SP.Data.ListItem. It is actually based on the name of the list when it was created. You can find the correct type at this endpoint.

/_api/web/lists/'getbytitle('[target list]')/listItemEntityTypeFullName

It will be something like SP.Data.TargetListListItem (assuming you named the list TargetList when it was created.

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.