API - Unable to get Emails by Program Id

HZ23
Level 1

API - Unable to get Emails by Program Id

Hi, I have the following folder structure.

|- Folder (id: 1123)

    |- Program (id: 3705)

       |-Folder (id: unknown)

          |- Email

 

When I call the endpoint: `https://{{munchkin}}.mktorest.com/rest/asset/v1/emails.json?maxReturn=60&folder={"id":3705,"type":"program"}` I get the following response:

{"success":true,"errors":[],"requestId":"565d#17b4032e97d","warnings":["No assets found for the given search criteria."]}

And when I run it by the parent folder (https://{{munchkin}}.mktorest.com/rest/asset/v1/emails.json?maxReturn=60&folder={"id":1123,"type":"Folder"}) I get the following response:

{"requestId":"17580#17b4033bc63","success":false,"warnings":[],"errors":[{"code":"711","message":"Invalid folder type for email"}]}

 

 My question is how can I get the emails that are part of the program? I have the program id but it does not return the data.

 

 

Tags (1)
4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: API - Unable to get Emails by Program Id

As I’d think is self-evident from your question itself, you need to get the ID of the folder, since that’s the actual parent of the email assets.

HZ23
Level 1

Re: API - Unable to get Emails by Program Id

yes, that's what I thought but the id of the folder inside of a program is nowhere to be found. Even on the Marketo platform, that folder is not clickable.

SanfordWhiteman
Level 10 - Community Moderator

Re: API - Unable to get Emails by Program Id


Even on the Marketo platform, that folder is not clickable.

Certainly they’re clickable (that’s how you open/close them). Maybe what you mean is they don’t change the URL in the UI, which is true.

 

They’re absolutely queryable via REST API, you need to browse the parent Program.

HZ23
Level 1

Re: API - Unable to get Emails by Program Id

So I was able to get the folder ids by calling the `/asset/v1/folder/{ProgramrId}/content.json?type=Program` I just had to pass the type as `program`. I was calling the program-related endpoints and it was not returning the sub-folders.

All good now. Thanks for the help.