1

I want to create as well as update an email using REST API.

I am using following documentation links:

  1. POST /asset/v1/content/assets
  2. PUT /asset/v1/content/assets/{id}

(https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/routes.htm)

I am able to retrieve content using GET API call (GET /asset/v1/content/assets).

However, I am not sure where to put the updated HTML code in my PUT or POST API request. Do I have to put it in URL or I have to put it in BODY of the API request? If BODY, then what would be the structure of the BODY? How my JSON would look like?

1

An example provided in the docs for adding content is below:

{
  "name": "NTO Welcome Series Email",
  "channels": {
    "email": true,
    "web": false
  },
  "views": {
    "html": {
      "content": "<!DOCTYPE html><body>This is a simple message.</body></html>"
    },
    "text": {},
    "subjectline": {},
    "preheader": {}
  },
  "assetType": {
    "name": "templatebasedemail",
    "id": 207
   }
}

You would set your new/updated html into the 'content' (views > html > content) section of the above JSON.

You can also view more samples here - including HTML Paste, Simple Template based and Complex template based emails.

1

I used Apex to update the content of a Html Email Template (AssetId = 208): on the code i have to use this header 'request.setHeader('X-HTTP-Method-Override','PATCH')' and made a POST action on the request to get success, and the json example is the following:

{  
   "views":{  
      "html":{  
         "content":"Here goes the html code of the template"
      }
   },
   "assetType":{  
      "name":"htmlemail",
      "id":208
   }
}

the url to call is the one that you mention: ../asset/v1/content/assets/{id}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.