URL in dictionary returns 404 Not Found

Frank_Oprel
Level 2

URL in dictionary returns 404 Not Found

I have created velocity script to render multiple downloads in one email. The idea is simple: a form contains a string field that's given the field type 'Checkboxes'; This field is appended with the values of each download that a person requests. In the script below, the string field is split into a list and checked against a dictionary (not sure if I'm using the right term here). However, the URL in dictionary returns a 404 error. I assume it's an escaping issue. But I don't have enough experience with Velocity's syntax to solve it.

#set( $category = "cyber" )  
#set( $downloads = {
"cyber" : {
"cyber-security-learning" : {
"url" : "https://view.example.nl/rs/834-ESS-180/images/Cyber-Security Brochure.pdf",
"button" : "Cyber Security Learing"
},
"cisa-certification" : {
"url" : "https://view.example.nl/rs/834-ESS-180/images/CISA-Certification Brochure.pdf",
"button": "CISA Certification"
},
"cism-certification" : {
"url" : "https://view.example.nl/rs/834-ESS-180/images/CISM-Certification Brochure.pdf",
"button" : "CISM Certification"
}
}
} )

#set ( $mktoList = ${lead.aCBrochures} )
#set ( $courses = $mktoList.split("; ") )

<ul>
#foreach ( $course in $courses )
#if ( $downloads[$category].containsKey(${course}) )
<li><a href="${downloads[$category][${course}]["url"]}">${downloads[$category][$course]["button"]}</a></li>
#end
#end
</ul>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Link path Marketo is trying to link to looks something like this:

http://view2.example.nl/dc/$mktEncrypt.encrypt($mkturl1)/uE0000wS4w0v0L03q7NESL0

Hope someone is able to help me out.

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: URL in dictionary returns 404 Not Found

checked against a dictionary (not sure if I'm using the right term here)

Map, or more fully, LinkedHashMap.

Hope someone is able to help me out.

You're running into a classic problem with tracked links & Velocity.

Read this thread and this blog post.

Also, please always highlight your code (as Java, that's the closest to Velocity) using the syntax highlighter so it's readable.

Frank_Oprel
Level 2

Re: URL in dictionary returns 404 Not Found

Hi Sanford,

Thanks for giving me some pointers. I will definitely check out those blog posts. Never posted code here, so good to know that it's possible to highlight code as Java.

Frank_Oprel
Level 2

Re: URL in dictionary returns 404 Not Found

Followed the steps on your blog. Works like a charm! Thanks for helping out Sanford