How to pass value that has commas in query string | Community
Skip to main content
New Participant
May 6, 2022
Solved

How to pass value that has commas in query string

  • May 6, 2022
  • 2 replies
  • 23059 views

Hi,

 

We have scenario that custom field having values like below,

 

Field Name: months

Record1 - Jan,Mar

Record2 - Mar, Dec

Record3 - Feb,Jul

 

so when i am trying to query via rest api, I need to use comma to separate multiple values. since comma is already present in the values, its not picking any records. How to escape commas in values? 

 

Please help.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Not so much a query string issue as a general delimiter collision issue (which would exist even if the value were, say, a JSON String).

 

Unfortunately I’m not aware of a way of escaping the comma delimiter. For fields storing multiple nested values, it’s recommended that you use semicolons (as Marketo does for fields linked to Selects, for example). Perhaps you can export and reimport these values and use the semicolon going forward.

 

 

2 replies

Darshil_Shah1
Community Manager
May 7, 2022

Agreed, there probably isn’t any way to get around this other than changing the delimiter character in the field value. I spent some time in going through similar use-case and tried all the possible way to escape the “,” character and send it in the request URL in a way so that Marketo considers the comma delimited value as a single value, but none seemed to be working.

 

Jo_Pitts1
Community Manager
May 7, 2022

@cptizo ,

If you google how to URL encode a comma, you'll find things like this.  

 

In short, use %2C instead of comma in a URL.  That being said, any good URL building library should handle that automatically for you.

 

Cheers,

Jo

SanfordWhiteman
New Participant
May 7, 2022

In short, use %2C instead of comma in a URL.  That being said, any good URL building library should handle that automatically for you.

That won’t actually work. The problem isn’t that the comma is a reserved character in a URL, it’s that a reserved character within the Marketo app. So either way Marketo sees a comma.