Re: Marketo Token Create API call throw 709 Business Rule Violation Error

tdesai
Level 2

Marketo Token Create API call throw 709 Business Rule Violation Error

I am running into an issue where my API call to create token is failing. The error response is 709 (Business Rule Violation) with message saying Not a valid Script Token value.

 

I am using the following documentation for reference - https://developers.marketo.com/rest-api/endpoint-reference/asset-endpoint-reference/#!/Tokens/addTok... 

 

Token data type = script block (NOTE: I did not find official documentation of this data type https://developers.marketo.com/rest-api/assets/tokens/)

 

Please check the HTTP request & response screenshots below.

HTTP Response

marketo_token_error_response_png_2739×1499_.png

HTTP Request

marketo-token-error.png

 
15 REPLIES 15
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

The script token type is deprecated via API; even when it works, you have to do some advanced Velocity to actually use the code.

 

The specific reason this call isn't working is because you aren't encoding the payload correctly, but I'd encourage you to avoid writing this token type via API. What is the overall logic that you're trying to implement from a business perspective?

tdesai
Level 2

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

I am trying to render dynamic content in the email. I am trying to do this by setting an array of json objects via the token API call  -

$defaultDocs velocity script variable eg.

 

 

#set($defaultDocs = [{id:1, url: 'test.url.com', title:'test link1'}, ...])

 

 

I have a separate token at the email program level (this one I set via MarketoUI and NOT via API call reason being this is "static" vs the above one) where-in I do a for loop over this array collection like so

 

 

 

#set($urls=[])
#foreach($doc in $defaultDocs)
$urls.add($doc.url)
#end
#foreach($doc in $defaultDocs)
#set($i = $foreach.count - 1)
<a href="https://${urls[$i]}">$doc.title</a>
#end

 

 

 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Token Create API call throw 709 Business Rule Violation Error


velocity script variable eg.
#set($defaultDocs = [{id:1, url: 'test.url.com', title:'test link1'}, ...])

Hmm, that's not valid Velocity code, though. (Nor is it valid JSON, though Velocity only supports a subset of JSON.)

 

Anyway....

 

Is this used in a Trigger context, Batch, or both? (Yes, this matters.)

 

 

 

 

tdesai
Level 2

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

Sorry about that I shared pseudo code to share my design.

We schedule the campaign (type is batch) via api call https://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Campa...

Here's the rectified code -

 

#set($defaultDocs = [{"Id":1, "Url": "test.url.com", "Title":"test link1"}, ...])

Our workaround is to refer to the lead object.
${lead.userId}#set($defaultDocs = [{"Id":1, "Url": "test.url.com", "Title":"test link1"}, ...])

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

Here's the rectified code -

#set($defaultDocs = [{"Id":1, "Url": "test.url.com", "Title":"test link1"}, ...])

OK, that'll compile at least. Note what I mean by "subset of JSON" is VTL literals don't support C-style escapes, nor the literal keyword null.

 

I don't understand what your workaround is intended to do, though.

tdesai
Level 2

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

In my work around I am accessing marketo object and I am thinking that is the reason it worked.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

 

${lead.userId}#set($defaultDocs = [{"Id":1, "Url": "test.url.com", "Title":"test link1"}, ...])

This code is just outputting a lead field directly before setting a variable.

 

tdesai
Level 2

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

Yes. Looks like if I access a marketo object in my script code then the API call to create the token is success and I don't get the 709 Business Violation Error. Again this is purely a workaround!

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Token Create API call throw 709 Business Rule Violation Error

Less a workaround than luck — if this works, it's because the parser that checks for valid content is broken, but there's no reason to assume it'll stay broken (esp. since the whole endpoint isn't supported).

 

I co-develop a commercial app that used to consume this endpoint, but we encountered far too many regressions over time and turned it off late last year. It's too risky to keep in production now.