Despite the docs saying it is possible and the describe request stating it is editable, I have not found a way to do this via SOAP API (Which is what WSProxy is currently running). I have tried both the 'Automation' SOAP Object as well as the undocumented old 'Program' SOAP Object with no luck. The only one I have found any success with is an undocumented REST API route. Perhaps if the rumors are true and there is a REST WSProxy coming out, this can be transitioned to WSProxy then.
See below:
PATCH /automation/v1/automations/{{autoID}}
Host: {{et_subdomain}}.rest.marketingcloudapis.com
Authorization: Bearer {{dne_etAccessToken}}
Content-Type: application/json
{
"categoryId": {{categoryID}}
}
In order to use this, you will need both the Object ID of the automation as well as the Category ID of the target folder.
The Automation Object ID would be inserted on the endpoint at the end to target the automation.
The Category ID would be added into the JSON payload to change it to the new folder.
As a note, you only need to include the parts you want changed inside the JSON of the call as the Automation is selected via the endpoint.
To translate this into SSJS to match what you are attempting to do via WSProxy would require you to do 2 API calls - an API call to get a token and then a second for the PATCH API call. (NOTE this will require you to have REST API credentials and scope to change this)
Something like below should work:
<script runat=server>
Platform.Load("Core","1.1.1");
var clientId = '{{myClientId}}';
var clientSecret = '{{myClientSecret';
var subDomain = '{{mySubDomain}}';
var authURL = 'https://' + subDomain + '.auth.marketingcloudapis.com/'
var restBase = 'https://' + subDomain + '.rest.marketingcloudapis.com/'
var version = 2;
var autoID = "{{myAutoID}}";
var catID = {{myCategoryID}};
var token = 'Bearer ' + generateToken(clientId, clientSecret, mid, authURL, version);
var res = patchAuto(restBase,autoID,catID);
function patchAuto(restBase,autoID,catID) {
var url = restBase + 'automation/v1/automations/' + autoID;
var req = new Script.Util.HttpRequest(url);
var payload = {"categoryid": catID}
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = 'PATCH';
req.postData = Platform.Function.Stringify(payload);
var resp = req.send();
var resultStr = String(resp.content);
var resultJSON = Platform.Function.ParseJSON(String(resp.content));
return resultJSON;
}
function generateToken(clientId, clientSecret, mid, authURL, version) {
if (version == 2) {
var versionEndpoint = '/v2/token'
var authJSON = {
"grant_type": "client_credentials",
"client_id": clientId,
"client_secret": clientSecret,
"account_id": mid
}
} else {
var versionEndpoint = '/v1/requestToken'
//URL changes for V1 endpoints
var authJSON = {
"clientId": clientId,
"clientSecret": clientSecret
}
}
var authUrl = authURL + versionEndpoint;
var contentType = 'application/json';
var authPayload = Platform.Function.Stringify(authJSON);
var accessTokenResult = HTTP.Post(authUrl, contentType, authPayload);
var statusCode = accessTokenResult["StatusCode"];
var response = accessTokenResult["Response"][0];
if(version == 2) {
var accessToken = Platform.Function.ParseJSON(response).access_token;
} else {
var accessToken = Platform.Function.ParseJSON(response).accessToken;
}
return accessToken;
}
</script>