"Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

Anonymous
Not applicable

"Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

Our Ticket:

Repro steps:
1. Have an existing program in Marketo.
2. Update the name to include this dash – via the "Update Program" card.
3. The name in Marketo will now contain – instead of –
4. Creating a program with – via the Marketo UI does not result in the same issue.

This may be affecting more than just the Update Program card. Maybe look into the other Program related actions and make sure they don't do the same thing.

Dev response:

The api expects data to be sent with "Content-Type: application/x-www-form-urlencoded" Header.

So including this header encodes the em dash but not the hyphen.
Without this header the data is not getting updated.
I tried adding "charset:UTF-8" , base64 encoding and percent encoding nothing worked.
It is a limitation on Marketo API

The problem with the API is the data should not be encoded but the header "Content-Type: application/x-www-form-urlencoded" encodes em dash only not the hyphen.

That’s why — changes into –

Solution Path:

We are looking for a way to successfully update program Titles with the provided string, and without encoding changing the input which switches the em-dash "–" to a-acute "â".

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: "Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

2. Update the name to include this dash – via the "Update Program" card.

Think you mean "endpoint," never heard "card" used this way.

The problem with the API is the data should not be encoded but the header "Content-Type: application/x-www-form-urlencoded" encodes em dash only not the hyphen.

Actually the HTTP header doesn't encode anything at all.

The header is intended to reflect encoding that you have done elsewhere. Often, calling an encoding routine also sets the header accordingly, or vice versa. But there's no automatic connection between the 2 in general (and it's easy to mess up by stating the wrong encoding for the actual payload).

You don't need to URL-encode the "–".   You can encode it (URL-encoded non-reserved characters always work) but you don't need to.

2. Update the name to include this dash – via the "Update Program" [API endpoint]

The api expects data to be sent with "Content-Type: application/x-www-form-urlencoded" Header.

I have no trouble at all including an emdash in the program name via the API.

pastedImage_2.png

The payload is just:

name=Program%20Lab%2016%20-%20API%20Creation%20-%20Updated%20-%20–

The Content-Type:

Content-Type: application/x-www-form-urlencoded; charset=utf-8

And it also works if the emdash is encoded:

name=Program%20Lab%2016%20-%20API%20Creation%20-%20Updated%20-%20%E2%80%93

It is a limitation on Marketo API

Nope. It's an error in your client code.

SanfordWhiteman
Level 10 - Community Moderator

Re: "Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

Lito Nicolai​ please return to this thread and mark my answer as correct.

When people respond to your threads promptly, you shouldn't abandon them...

Anonymous
Not applicable

Re: "Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

Thank you for your response Sanford, and my apologies for not promptly responding as you did.  I was just able to take a look at this today, and I have forwarded this to my developer.  I will come back and mark this answer as correct after the solution has been applied successfully.

Anonymous
Not applicable

Re: "Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

Hello Sanford,

Our developer attempted to implement your suggested solution with failure.  Here is their response:

I had tried all the above mentioned solutions both in our environment and postman prior to requesting Marketo support, and now I have tried all the provided solutions again today. It doesn't solve the issue.

For further info to this bug I’m going to attach the postman code, because it shows there is nothing wrong with the client code.

Postman Request Code:

```
POST /rest/asset/v1/program/{programId}.json HTTP/1.1
{‌{Host: 149-ZXA‌-775.mktorest.com}‌}
Authorization: Bearer <<access_token>>
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: <<token>>

name=Program%2520Lab%252016%2520-%2520API%2520Creation%2520-%2520Updated%2520-%2520%E2%80%93

```

Response:

```

"success": true,

"errors": [],

"requestId": "f4e0#166148ca266",

"result": [

"id": {programId},

"name": "Program%20Lab%2016%20-%20API%20Creation%20-%20Updated%20-%20â\u0080\u0093",

"description": "ntng",

"createdAt": "2018-09-26T06:23:27Z+0000",

"updatedAt": "2018-09-26T06:24:13Z+0000",

"url": "https://app-ab08.marketo.com/#PG1385A1",

"type": "Default",

"channel": "Blog",

"folder": {

"type": "Folder",

"value": xxx,

"folderName": "xxxxxx"

},

"status": "",

"workspace": "Default",

"tags": [],

"costs": []

}

]

}

```

Here is a provided picture for the Project Name in the UI after making this call:

Capture.PNG

Also, here is documentation that is being referenced: http://developers.marketo.com/rest-api/endpoint-reference/asset-endpoint-reference/&#35;&#33;/Progra...

SanfordWhiteman
Level 10 - Community Moderator

Re: "Update Program" doesn't encode special characters correctly (specifically the em dash – as opposed to the hyphen - )

The error is still in your developer's code. It's easy to see this if you compare your example with mine -- close inspection is a key skill for a professional developer.

You can see in your example the %20 is being double-encoded to %2520. This is incorrect.  Spaces must appear as %20, standard percent-encoding, in the request.

Also, please highlight your code as JavaScript using the Advanced Editor's syntax highlighter for readability.

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

Lucas_Metherall
Level 4

Re: "Update Program" doesn't encode special characters correctly (specifically the em dash

ouch.

 

I just need an em dash in the copy of an email.. Any ideas?