Hi Team,
I am trying to post an action using the ajax Query so what i have done till now is i have converted the API call in AJAX Format -
var requestBody = '<?xml version="1.0" encoding="UTF-8"?><BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd"><SingleAction><Title>Image Move</Title><Relevance>true</Relevance><ActionScript MIMEType="application/x-Fixlet-Windows-Shell">delete "C:\Program Files (x86)\BigFix Enterprise\BES Client\download.jpg" copy "C:\soft\download.jpg" "C:\Program Files (x86)\BigFix Enterprise\BES Client\download.jpg"</ActionScript><SuccessCriteria Option="RunToCompletion"></SuccessCriteria><Target><ComputerName>ptest0056</ComputerName></Target></SingleAction></BES>';
$.ajax({
url: "https://10.1.150.77:52311/api/actions",
success: function(data) {
$("#update_response .update-text").html("You have successfully updated photo<strong>");
$("#update_response").show();
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus, errorThrown);
},
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("bigfix_admin" + ":" + "Admin098!"));
},
type: 'POST',
dataType: 'xml',
contentType:'application/xml',
cache: false,
data:requestBody
});
But we are not able to open any action by this method.
However when we are posting it via cURL or IEMCLI it is working perfectly fine.
Example how we are posting it via IEM CLI.
We exported the action and then used
iem login --server=https://10.1.150.77:52311 --user=bigfix_admin --password=Admin098!
and then out Xml file - test.xml
<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SingleAction>
<Title>Image Move </Title>
<Relevance>true</Relevance>
<ActionScript MIMEType="application/x-Fixlet-Windows-Shell">delete "C:\Program Files (x86)\BigFix Enterprise\BES Client\download.jpg"
copy "C:\soft\download.jpg" "C:\Program Files (x86)\BigFix Enterprise\BES Client\download.jpg"</ActionScript>
<SuccessCriteria Option="RunToCompletion"></SuccessCriteria>
<Target>
<ComputerName>ptest0056</ComputerName>
</Target>
</SingleAction>
</BES>
Then posting it using - IEM CLI
iem post “test.xml” actions .
However this is working fine can anyone please help checking why we are not able to post the action using the AJAX call.