SOLVED

How to pass value that has commas in query string

Go to solution
cptizo
Level 1

How to pass value that has commas in query string

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.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: How to pass value that has commas in query string

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.

 

 

View solution in original post

4 REPLIES 4
Jo_Pitts1
Level 10 - Community Advisor

Re: How to pass value that has commas in query string

@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
Level 10 - Community Moderator

Re: How to pass value that has commas in query string


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.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to pass value that has commas in query string

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.

 

 

Darshil_Shah1
Level 10 - Community Advisor

Re: How to pass value that has commas in query string

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.