Search for features with single quotes in the value.

3440
1
10-30-2014 03:57 PM
ReneRubalcava
Frequent Contributor

So I have some street data where a field I am searching on has some values that look like

135' S/O Main St

This is causing problems when trying to search for these with the ArcGIS REST API.

I've tried using the following

135%27 S/O Main St

But that doesn't work either. I know they are there because I can search on the ID and they come back in results, but I need to search on the actual value.

Any tips? Anyone run into this before?

Thans.

Tags (1)
0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

So there doesn't seem to be an easy way around this, even trying to do the query directly in ArcMap.

What I ended up doing, since I am using this in a backend service anyway was to check if a single quote was in the request, create a substring up the index location of the single quote, do a LIKE request with a wildcard and from the results, find the one that matches the original request.

It would look something like this in .NET.

string m_search = search;

bool hasQuote = search.Contains("'");

if (hasQuote == true)

{

  m_search = search.Substring(0, search.IndexOf("'"));

}

// do API request and get response

// string where = "where=FIELDNAME LIKE '" + m_search + "%'";

var features = response["features"];

List<object> list = new List<object>();

for (int i = 0; i < features.Length; i++)

{

  var feat = features;

  var attr = feat["attributes"];

  if (attr["FIELDNAME"] == search)

  {

    list.Add(attr);

  }

}

return list;

It seems to be working ok so far and not's noticeably slower in my current queries.

In case anyone else comes across this problem, that's how I figured it out.