Skip to main content
added 202 characters in body
Source Link

Also I have attached the response when i stringify the payload I am assuming that the /n/n spacing problem could be one of the issue

Also I have attached the response when i stringify the payload I am assuming that the /n/n spacing problem could be one of the issue

Source Link

Patch request to update html content for an asset in SFMC

I am updating the asset in SFMC using the below mentioned API / SSJS code :

var assetIdToUpdate = "115271"; // Replace with the actual asset ID you want to update
var assetHTML = rest_instance_url + "/asset/v1/content/assets/" + assetIdToUpdate; 

var headerNames = ["Authorization"];
var headerValues = ["Bearer " + accessToken];
var contentType = 'application/json'
var assetHTMLresponse = HTTP.Get(assetHTML, headerNames, headerValues);
var assetHTMLcode = assetHTMLfinalresponse.views.html.content;
var assetHTMLname = assetHTMLfinalresponse.name;
var assetHTMLdescription = assetHTMLfinalresponse.description;
var assetHTMLID = assetHTMLfinalresponse.assetType.id;

var payload = {
                name: assetHTMLname,
                description: assetHTMLdescription,
                channels: {
                    email: true,
                    web: false
                },
                assetType: {
                    name: "htmlemail",
                    id: assetHTMLID
                },
                views: {
                    html: {
                        content: assetHTMLcode
                    }
                }
            };

          
            var req = new Script.Util.HttpRequest(assetHTML);
            req.emptyContentHandling = 0;
            req.retries = 2;
            req.continueOnError = true;
            req.contentType = "application/json"
            req.setHeader("Authorization", headerValues);
            req.method = "PATCH"; // Use PATCH method for updating existing resources
            req.postData = String(payload);

            var resp = req.send();

            var resultJSON = Platform.Function.ParseJSON(String(resp.content));
            
          
            Write(Stringify(resultJSON)); 

However when I publish the cloud page I am getting the below mentioned error

{"message":"Unable to retrieve security descriptor for this frame.","description":"System.InvalidOperationException: Unable to retrieve security descriptor for this frame. - from mscorlib\r\n\r\n"}