Get email data of an email inside a program via API

Highlighted
Level 2

Get email data of an email inside a program via API

Hi All,

So I'm looking at this API endpoint reference:http://developers.marketo.com/rest-api/endpoint-reference/asset-endpoint-reference/#!/Emails/getEmai... and there's an option to pass folder related data as JSON representation as mentioned here: http://developers.marketo.com/rest-api/assets/emails/#by_name but when I'm trying to test it on Postman I get the message that the "Folder id is not valid". I'm just trying to figure out what is the correct method to pass that json representation besides the email name to the GET request endpoint url. Surely I don't want to treat mkto nation as stackoverflow, though it would be great help in my code with your suggestions/recommendations.

Thanks

9 REPLIES 9
Highlighted
Level 6

Re: Get email data of an email inside a program via API

Declare a Folder ID and pass it in a param.  If your folder ID is "97" then your url should look like this:  /rest/asset/v1/email/byName.json?folder=97

Note there is a difference between folders and programs.

Here's a full endpoint for reference: /rest/asset/v1/email/byName.json?accesstoken=something&name=something&folder=97

Highlighted
Level 2

Re: Get email data of an email inside a program via API

Hi Jim,

Thank you for your response. Appreciate it, although I want to know if I want to pass the Id of the program and not the folder, would I be defining the program Id in the same manner or follow some other syntax? The email whose data I want to read resides in an email blast program.

Thanks.

Highlighted
Level 10 - Community Moderator

Re: Get email data of an email inside a program via API

Well, the example in the docs is wrong (this happens) as the JSON is broken (using = after the property name instead of :, and it also uses curly quotes!).

If you pass well-formed JSON you'll be fine:

folder={"id":3789,"type"="Program"}

which of course goes on the wire as

folder%3D%7B%22id%22%3A3789%2C%22type%22%3D%22Program%22%7D

or you can (I don't know if this is documented) use the shorthand

program=3789

You can't do exactly what Jim said for emails as they only support Programs (folder type=Program) as parents.

Highlighted
Level 2

Re: Get email data of an email inside a program via API

Sanford Whiteman​ I tried using the format suggested by you and for the first time I did get the result, but after testing for different "email blast" programs, I'm only getting the following result:

{

    "success": true,

    "errors": [],

    "requestId": "f179#16275e0de52",

    "warnings": [

        "No assets found for the given search criteria."

    ]

}

I know it's mentioned in the dev docs that the result will contain the warnings data as well, but I'm not getting the data for the emails that I search by name. Plus my email program has many emails with same prefix (say xyz-email1, xyz-email2). I'm not sure where I'm wrong. I hit the endpoint with parameters : &name=xyz-email1&folder={"id":3172,"type"="Program"}. I mean this should render me results because I checked all the points before testing.

&folder={"id":3172,"type"="Program"}

Highlighted
Level 10 - Community Moderator

Re: Get email data of an email inside a program via API

I'd have to see the results for an Email by ID and Program by ID for the same asset to tell you what you're missing.

Highlighted
Level 2

Re: Get email data of an email inside a program via API

Hi,

Were you able to find something? Let me also give you the full context: I'm trying to update one editable section of the email via the API, but all I have is the name available and not Id of that email and any API operations with a mkto email requires its Id. That is why I'm trying to get its Id by its name but the problem is that a lot of emails have the same name living in different programs.

Highlighted
Level 10 - Community Moderator

Re: Get email data of an email inside a program via API

I was asking for the two sets of requests/responses above for a known ID. Without this info, I won't be able to see what might be off in the way you're querying. I can't reproduce any problem based on your general description.

Please use the Advanced Editor's syntax highlighter when posting the JSON:

pastedImage_2.png

Highlighted
Level 2

Re: Get email data of an email inside a program via API

Sanford Whiteman​ so I was able to figure out the reason I was getting no result but the warnings, is because when I tested it with emails not in folder but directly under the program, I got the results but when I move those emails inside a folder within the program then I get the warnings and no result. It seems that the program or folder has to be a direct parent of the asset, which I find irrelevant in such queries since our program is hierarchically structured. Could you confirm this at your end as well?

Thanks.

Highlighted
Level 10 - Community Moderator

Re: Get email data of an email inside a program via API

This is the expected behavior. Strict parent-child links (not generic "ancestor" links) is the way you query your folder hierarchy, so naturally it's the way you look for assets as well.