@MichaelStranks would be very interested to know more details about your solution. Specifically, did you have to escape any special characters to get your POST working?
@zezutom I checked out your Makker GitHub repo, nice work! I do really like your idea for it to expose an endpoint that could modify and post Blueprints, could be powerful. That said, like @Albanmana, I am also not experienced with Kotlin. In addition, having to use and deploy a separate app to form the correct requests from a no-code app is not ideal so I’m conflicted
Tammy I know the answer is likely no longer relevant but here are two solutions to the problem with the hopes that others might benefit from the information / contribute to improving it:
UPDATE: SEE GREATLY IMPROVED METHOD IN NEXT POST
The Dynamic Approach
- Add a “Make an API Call” module from the Make app. GET the
/v2/scenarios/<scenarioId>/blueprint
URL. Note: This source scenarioId could be a template of sorts, or you can make multiple calls to multiple source scenarios to compose in the next step as you suggest. - Convert the response to a JSON string by adding a “Transform to JSON” Module and using the body.response.blueprint object as the source.
- Add one or more “Replace” modules with the output of the previous step as a source. This will allow you to use a RegEx to modify the contents. You may also want a “Compose a String” step to combine multiple elements. Based on my testing, there is a requirement for at least one Replace module to escape doublequotes (") with the backslash . So " → "
- Repeat steps 2 and 3 for the body.response.schedule object
- Add a “Make an API Call” module from the Make app. PATCH the
/v2/scenarios/<scenarioId>/blueprint
URL. Add a JSON Content-type header and the following to the body:
{"blueprint":"{{##.convertedBlueprint}}", "scheduling":"{{##.convertedSchedule}}"}
The big caveat with this approach is that while it works for simple flows, especially those that have not been run, I’ve not been able to figure out the correct steps to clean the Blueprint once the flow runs or is more complicated resulting in more special characters and combinations in the Blueprint.
IF ANYONE KNOWS THE CORRECT SEQUENCE OF REPLACE AND REGEX TO USE OR ANOTHER WAY TO DO THIS, I’D BE ENORMOUSLY APPRECIATIVE.
I have a ticket in to Make support about it but they’re really slow to reply. Will update if I hear back.
The Static Approach
- Add a “Compose A String” module. Paste the Blueprint into the text. I have found the easiest way to get a properly escaped Blueprint string is to use my browser’s Dev Tools to inspect the call being made when you save a scenario. Then download the RAW version. Another trick here is to avoid Make trying to reference modules in the text, like @MichaelStranks pointed out, I replace all instances of { with | in the string before pasting it.
- Add one or more “Replace” modules with the output of the previous step as a source. This will allow you to use a RegEx to modify the contents. You may also want a “Compose a String” step to combine multiple elements. There is no need to escape special characters with this approach but you do need one Replace step to convert those | characters back to {.
- Same as last step of the dynamic approach
Overall, both approaches are not great so if anyone has found better solutions, I think the community would benefit from hearing it!
CCs:
@PraneethG as I see you had a similar issue.
@alex.newpath I see you suggested using the map() function for replacing parts of the JSON however my testing seems to suggest that map() can only handle Arrays and the response from the call to the API is a deeply nested object. It would also require re-composing a very complicated object. Because of these issues I’m not sure if this would work? Admittedly I’m not well practiced using the map() function so if you have some tips for using this approach I think I’d be a big win.