1

Do anyone have any idea how we can query on email body/email content ?

I've a use case where I want get all the email name in which I've used a certain number 878XXX784741 and have sent those emails to subscribers.

I thought first if that number would be used in href tag, so I should query _Click data view and through linkname or URL field I hope I can get the result. But no luck!

Any suggestions?

1

You can achieve that by doing REST API call to the GET /asset/v1/content/assets endpoint and then adding on top either Simple Query or Advanced Query to filter the results based on your need.

In your case, it is going to look something like that with the only condition: Content has "878XXX784741" -

https://[your_domain].rest.marketingcloudapis.com/asset/v1/content/assets?$filter=Content%20like%20'878XXX784741'
5
  • Hey @Niko - Thanks for the solution, but I'm not getting the exact number what I want. It's giving matching with 1st 4 digit of number. I'm getting huge results due to that. I want exact number to be searched used in emails. How can I filter that?
    – darkCloud
    Oct 29 '21 at 9:09
  • You can try doing an Advanced Query with a more specific search to narrow down the results.
    – Niko
    Oct 30 '21 at 8:57
  • Hey @Niko - Thanks for the suggestion and solution provided. But now I've achieved this through doing query in body not passing through URL. Please find my updated answer on this question
    – darkCloud
    Nov 11 '21 at 7:45
  • Hey, @darkCloud that is what is called Advanced Query and I was referencing it in my answer and comment above, so you basically did what I suggested to you from the very start.
    – Niko
    Nov 11 '21 at 8:26
  • Hi @Niko - Yes I tried the one that you suggested, although I was not comfortable how should I use advance query.. but read some post and article then got to know how it works. But really thanks for the suggestion and comment :)
    – darkCloud
    Nov 11 '21 at 10:23
0

I'm finally able to achieve this through below solution.

Method : POST

URL:https://[your_domain].rest.marketingcloudapis.com/asset/v1/content/assets/query

Body :

{
    "query":
    {
        "leftOperand":
        {
            "property":"content",
            "simpleOperator":"mustcontain",
            "value":"[878XXX784741]"
        },
        "logicalOperator":"AND",
        "rightOperand":
        {
            "property":"assetType.name",
            "simpleOperator":"equal",
            "value":"htmlemail"
        }
    },

    "sort":
    [
        { "property":"id", "direction":"ASC" }
    ],

    "fields":
    [
        "enterpriseId",
        "memberId",
        "thumbnail",
        "category",
        "content",
        "data"
    ]
}

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.