How to execute the Macro API parameterized?
Hi everyone,
I just found out that there is the possibility to execute the Macro API with parameters. This would be great as I currently use a sketchy workaround.
My API documentation doesn't say anything about the parameters, and this is what I have found in one of the XTRF documents:
Parameterized Macros Available via API calls
Why? HP REST API didn't officially support executing XTRF Macros. Macros didn't support additional parameters
that could modify their behavior. Support for macro parameters has been added.
What? API call POST /macros/{macroId}/run enables executing a macro operation with parameters.
Where? Home Portal API.
Reference: DEV-7597
Did someone get this to work already? Or can XTRF tell me what needs to be done in order to get the parameters to get over to the macro?
Kind regards,
Dennis Rosenbaum
Customer support service by UserEcho
Hey Dennis,
It really is useful. I asked support about this a while ago, and this is their answer (summarized):
- the 'ids' specified in the API call refer to the element(s) you want to run the macro on. You can use them in the macro using the 'list' variable as usual.
- the params can be any valid json. So:
would be OK, and then in the macro, I could use
to access it.
Hope this helps.
Dankjewel, Thanx Thijs,
I'm going to try this out.
This will be way better than our current workaround.
Dennis, I also use this. If you need some help, contact me.
Great! Thank you for your help Thijs and Viktor for your support.
I have managed to get it to work and implemented it in our own software framework. Wasn't a tough one, as the implementation is rather straightforward.
@XTRF
As a suggestion, I would like to prompt for an update of the Macro API documentation. Currently it states that you can use the params variable, but this hasn't been useful as we didn't have a clue on how to use it.
The example that Thijs has given is enough to understand how it works and how anyone could work with it. So for new API users, it would be rather usefull to have this information.