Reputation: 17552
I'm trying to create an Azure Logic App that broadly does the following:
Use a HTTP call to a REST service, the REST service will return JSON with Ids. This is working fine, the resulting JSON looks a bit like this: "workItems" : [ { "id": 118, }, { "id": 119, }, etc ]
I need to extract all the Ids, and put them into a comma separated string, e.g. 118, 119, etc
.
The comma separated string will then be used as part of another HTTP REST call.
However I'm struggling at point 2. I cant see where I can write some script or code (without building a custom logic app component) to do this transformation.
At the moment I've tried using the BizTalk Apps to convert the JSON to XML, then use XPath, then hopefully get that back into a string at some point - but this whole process seems overly complicated.
I realise I could write a custom app, but if I did that then I might as well just do all the work in the custom app as well. Be nice to use the native features of Azure if possible.
I'm afraid I might be missing something obvious. Suggestions would be appreciated.
Upvotes: 1
Views: 3010
Reputation: 8505
WebJobs Webhooks are now deprecated. Use Azure Functions Generic Webhooks instead - they have direct integration support with Logic Apps.
One option is to use a WebJob Webhook and do the transformation/filter there. I have an example on GitHub of using this to filter posts to Slack. If you already have a Web/Mobile/API app up and running, it's easy to have a WebJob hosted on it so you don't need additional resources, necessarily.
Your other option, you highlighted. Deploy an API App which will do the xform for you.
If you want to go down the WebJob route and need any help, let me know and I'll be glad to assist.
Upvotes: 0
Reputation: 63
Try the CsScripting Api. It enables you to do some simple c# code and has the NewtonSoft libs available. I usually write the code as a console app for testing first before plugging it into the logic app action.
Upvotes: 4