Reapply/Retry with SourcedFixletAction

Greetings, I am new here so please be kind :wink:

I am working with PowerShell to create tasks via the API. I have it working fine using the XML below. What I cannot figure out is how do I set the REAPPLY and RETRY options while scheduling the task? When I add them under SETTINGS my request fails. I found on the forum mention of a slightly different XML structure to be used with SourcedFixletAction, but the link in that post goes to a dead webpage.

------XML------

<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
    <SourcedFixletAction>
        <SourceFixlet>
            <Sitename></Sitename>
            <FixletID></FixletID>
            <Action>Action1</Action>
        </SourceFixlet>
        <Target>
        </Target>
        <Settings>
            <HasStartTime>true</HasStartTime>
            <StartDateTimeLocal></StartDateTimeLocal>
            <HasEndTime>true</HasEndTime>
            <EndDateTimeLocal></EndDateTimeLocal>
            <UseUTCTime>true</UseUTCTime>
            <PostActionBehavior Behavior="Nothing">
                <AllowCancel>false</AllowCancel>                
            </PostActionBehavior>
        </Settings>
        <Title></Title>
    </SourcedFixletAction>
</BES>

Hello, and welcome!

Do you happen to have examples of what you’ve tried for reapply and retry options?

For reference to the XML schema definition, please see https://developer.bigfix.com/rest-api/schema_files.html. As it says, you can find the XSD files from the Root Server itself (via the filesystem or via https), or you can even find them today in the Utilities section of the downloads pages for the given version:

https://software.bigfix.com/download/bes/110/util/BES11.0.1.104.xsd
https://software.bigfix.com/download/bes/110/util/BESAPI11.0.1.104.xsd

That said, here is a sample <Settings> section that includes some reapply/retry behavior:

<Settings>
	<Reapply>true</Reapply>
	<HasReapplyLimit>true</HasReapplyLimit>
	<ReapplyLimit>3</ReapplyLimit>
	<HasReapplyInterval>false</HasReapplyInterval>
	<HasRetry>true</HasRetry>
	<RetryCount>3</RetryCount>
	<RetryWait Behavior="WaitForInterval">PT1H</RetryWait>
</Settings>

One tip that can help here: if you have access to the Console or WebUI and can create actions with the desired behavior via the UI, you can then export the action definition (in the Console, right-click the Action and select ‘Export Action’ OR you can also access the XML definition via the REST API through /api/action/<action id> - https://developer.bigfix.com/rest-api/api/action.html). This action XML definition can then be used as an example that you can adjust for your purposes to deploy via the API.

2 Likes

I did do just that - copied the XML from the API url of another action with the settings I want… all I get is “REQUEST FAILED” here is the XML I am using that fails:

<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
    <SourcedFixletAction>
        <SourceFixlet>
            <Sitename></Sitename>
            <FixletID></FixletID>
            <Action>Action1</Action>
        </SourceFixlet>
        <Target>
        </Target>
        <Settings>
            <PreActionCacheDownload>true</PreActionCacheDownload>
            <Reapply>true</Reapply>
            <HasReapplyLimit>false</HasReapplyLimit>
            <HasReapplyInterval>false</HasReapplyInterval>
            <HasRetry>true</HasRetry>
            <RetryCount>99</RetryCount>
            <RetryWait Behavior="WaitForInterval">PT10M</RetryWait>
            <HasStartTime>true</HasStartTime>
            <StartDateTimeLocal></StartDateTimeLocal>
            <HasEndTime>true</HasEndTime>
            <EndDateTimeLocal></EndDateTimeLocal>
            <UseUTCTime>true</UseUTCTime>
            <PostActionBehavior Behavior="Nothing">
                <AllowCancel>false</AllowCancel>                
            </PostActionBehavior>
        </Settings>
        <Title></Title>
    </SourcedFixletAction>
</BES>

Just to check…in your real XML you have some actual values filled in for ‘SiteName’, ‘FixletID’, ‘Target’, and ‘Title’ ?

Yes I do. those are passed through the powershell script. This works perfect without the XML keys for PreactionCacheDownload, Reapply and Retry stuff.

Ok, I reproduced this. A common issue is that the ActionSettings node is defined as a sequence - all the elements in Settings, if they appear at all, must be present in the correct order.
I put together a sample XML based on what I think the settings are that you’re trying to produce -

<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
  <SourcedFixletAction>  
	<SourceFixlet>    
        <!-- 168	BES Client Setting: CPU Usage; Action2 is default CPU -->        
		<Sitename>BES Support</Sitename>  

		<FixletID>168</FixletID>
		<Action>Action2</Action>
	</SourceFixlet>  
    
	<Target>  
        <ComputerName>BES-Root</ComputerName>                
	</Target>
    <Settings>
            <HasStartTime>true</HasStartTime>
            <StartDateTime>2024-03-30 12:00:00</StartDateTime>
            <HasEndTime>true</HasEndTime>
            <EndDateTime>2024-03-30 12:10:00</EndDateTime>
            <UseUTCTime>true</UseUTCTime>
            <PreActionCacheDownload>true</PreActionCacheDownload>
            <Reapply>true</Reapply>
            <HasReapplyLimit>false</HasReapplyLimit>
            <HasReapplyInterval>false</HasReapplyInterval>
            <HasRetry>true</HasRetry>
            <RetryCount>99</RetryCount>
            <RetryWait Behavior="WaitForInterval">PT10M</RetryWait>
            <PostActionBehavior Behavior="Nothing">
                <AllowCancel>false</AllowCancel>                
            </PostActionBehavior>
        </Settings>
 </SourcedFixletAction>
</BES>

In addition to rearranging some of your element order, I changed your StartDateTimeLocal and EndDateTimeLocal to StartDateTime and EndDateTime since you appear to be trying schedule in UTC time rather than endpoint local time, right?
edit: fixed some quote backslash-escapes that were a copy/paste artifact from the script

2 Likes

Yes! That worked! Thanks a ton!

1 Like