Frage

Due to lack of a built-in Modern Calendar interface and our corporation's restrictions on what we can do within the sites in our tenant, I'm trying to build a Flow in Power Automate that copies calendar entries from an Events List in one site collection to an Events List in a different site collection.

At first I tried to use the item information provided in the triggerBody() of the created/modified trigger to create the new calendar entries, but there are hidden columns that aren't available through that interface (either to get or set in the newly created item). So I had to move on to Send an HTTP request to SharePoint step to get all the columns I need. This seems to be working and I get some a JSON response that looks like this:

{
  "d": {
    "ID": 37,
    "Title": "Simple single event",
    "Modified": "2020-01-23T23:24:10Z",
    "Created": "2020-01-23T23:24:10Z",
    "EventDate": "2020-01-25T00:00:00Z",
    "EndDate": "2020-01-25T01:00:00Z",
    "Description": "<p>Description goes here!​</p>",
    "fAllDayEvent": false,
    "fRecurrence": false,
    "EventType": 0,
    "UID": null,
    "RecurrenceID": null,
    "Duration": 3600,
    "RecurrenceData": null,
    "MasterSeriesItemID": null
  }
}

I follow up the request step with a Parse JSON step and I used this tutorial to modify the schema and to either convert the values to appropriate types or to accept no value or null. When I run a test, the output body for the parse looks right to me. I see what I have above and there are now dynamic variables for me to access. It looks right to me because things that are strings are in quotes, numbers and booleans have no quotes and are blue, same with null. It all appears to be a correct strongly typed version of the provided JSON.

My problem comes in trying to use that parsed JSON data with a REST POST to create a new item. Using the dynamic data names parsed by the previous steps the strings I manually construct a body like this:

enter image description here

I have to add quote marks for the ones I know will be strings, but for the booleans (fAllDayEvent or fRecurrence) I don't see that false gets changed to False. And for the ones that could be null I don't know what to do. I want to pass null and not "null". But at other times the null values might actually be strings and at that point they would need to have quotes. I just can't seem to coerce the parsed values back into acceptable JSON format.

I can't find anything to help with this because all searches point back to the Parse JSON action. And maybe that is the solution, but I'm not seeing how.

Any idea how to pass the parsed JSON value to a REST POST create item endpoint in correct JSON value format, when it might be null, string, or number depending?

War es hilfreich?

Lösung

I think you might be better off using the "Compose" action with the value set to body('Name_Of_Your_Http_Request_To_SharePoint_Action')?['d'] Then you can use another Compose step, in conjunction with removeProperty to remove the ID and addProperty to add the _metadata object. This way you would be guaranteed to pass all the values in the same format as you received, rather than trying to rebuild your JSON from scratch.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top