Discussions

REST API created email to location of a folder/sub-folder ?

Wayne Chan-Oracle
Wayne Chan-Oracle Posts: 34 Employee
edited Apr 18, 2020 6:33PM in Developer Tools

Hi,

I am using email creation API to create new email but it is always created in the top level directory of email folder of Eloqua. Is there a way to set the location of the created email to a folder or hierarchy of folder/subfolder. This is the the REST API end point I'm using :/api/REST/1.0/assets/email

thanks,

Wayne

Post edited by Unknown User on
Tagged:

Answers

  • Wayne Chan-Oracle
    Wayne Chan-Oracle Posts: 34 Employee
    edited Apr 17, 2020 7:44PM

    use folderId to set the desired folder from which the email is to be created. However how do get the value of folderId ?? I don't seem to see any API endpoints to allow this ?? One can manually find the folderId value by using another API endpoint : /api/rest/2.0/assets/emails  or /api/rest/2.0/assets/email/{email-id} to list all an email to list the folderId given you know ahead the email(s) is/are located in the folder by name. Then use one of the above API endpoints to enlist emails to get the folderId.

    If there is an API to return folderId somehow would be perfect.

    Wayne

  • Wayne Chan-Oracle
    Wayne Chan-Oracle Posts: 34 Employee
    edited Apr 18, 2020 6:33PM

    example of using folderId to set destination folder of email to be created : /api/rest/2.0/assets/email

    api request in JSON:

    {

        "name": "Email in Testing Area folder",

        "encodingId": 1,

        "emailGroupId": 1,

        "folderId": 416,   <===== destination of folderId

        "subject": "Test setup email in Testing Area folder",

        "htmlContent": {

            "type": "RawHtmlContent",

            "html": "<html><head></head><body>Create email in Testing Area folder.</body></html>"

        }

    }

    The prerequisite is to get destination folderId before making the above API email creation call. The problem is there is no API to directly query for the destination folderId. The way to obtain such information is to find an email from the destination folder using Eloqua login console. Then use /api/rest/2.0/assets/email/emails to query all emails from Eloqua. Then identify the email from which you know is in the destination folder and get the folderId from the entire query email list. This could be cumbersome if you have lots of emails on your Eloqua instance. perhaps you can dump you entire output to an editor and use its search function to locate the name of the email then to retrieve the folderId from the JSON block. Not straight forward and requires some manual processing.