Illegal character in query at index --salesforce - salesforce

Getting this error:
Illegal character in query at index 61:
https://cs4.salesforce.com/services/data/v32.0/query?q=Select +AppId__c,Technical_Review_Approved__c +From Application__c + Where + AppId__c+= '1793poiuyt'
Even tried this:
String url = "/query?q=";
String getRecords = url + "Select AppId__c,Technical_Review_Approved__c From Application__c Where AppId__c= '1793poiuyt' " ;
Caused by: java.net.URISyntaxException: Illegal character in query at
index 61:
https://cs4.salesforce.com/services/data/v32.0/query?q=Select AppId__c,Technical_Review_Approved__c From Application__c Where AppId__c= '1793poiuyt'

You can't have spaces in a URL. Check the REST Developer Guide: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm.
An example: https://na1.salesforce.com/services/data/v20.0/query/?q=SELECT+name+from+Account -H "Authorization: Bearer token"

Related

org.apache.solr.search.SyntaxError: Cannot parse sku_str

See below error:
"error": {
"msg": "org.apache.solr.search.SyntaxError: Cannot parse 'sku_str:VFY:A5440M35A5ME': Encountered \" \":\" \": \"\" at line 1,
column 11.
code": 400 }
Escape solr query string , See below function
SolrUtils::escapeQueryChars — Escapes a lucene query string
http://php.net/manual/en/solrutils.escapequerychars.php

Not able to access MSSQL analysis services cubes

I am using the following code to access mssql analysis services cubes from java using OLAP4j 1.1.0
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
OlapConnection con = (OlapConnection)
DriverManager.getConnection("jdbc:xmla:Server=http://mssql.com/mssql/msmdpump.dll;"+
"Cache=org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache;"+
"Cache.Name=MyNiftyConnection;Cache.Mode=LFU;Cache.Timeout=600;Cache.Size=100",
"username", "password");
OlapWrapper wrapper = (OlapWrapper) con;
OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
OlapStatement stmt = olapConnection.createStatement();
CellSet cellSet = stmt.executeOlapQuery("SELECT {" +
" [Measures].[LoginTime_Format]," +
"[Measures].[EngageTime_Format]," +
"[Measures].[ChatTime_Format]," +
"[Measures].[AverageHandleTime_Format]," +
"[Measures].[MultipleChatTime_Format]," +
"[Measures].[NonEngagedTime_Format]," +
"[Measures].[TimeAvailable_Format]," +
"[Measures].[TimeAvailableNotChatting_Format]," +
"[Measures].[TimeNotAvailable_Format]," +
"[Measures].[TimeNotAvailableChatting_Format]," +
"[Measures].[AcdTimeouts]," +
"[Measures].[AvgConcurrency]," +
"[Measures].[OperatorUtilization]} ON 0," +
" NON EMPTY ([DimTime].[CalenderDayHour].[CalenderDayHour], [DimAgent].[Agent]."+
"[Agent],[DimAgent].[Agent Name].[Agent Name]) ON 1" +
" FROM (SELECT [DimClient].[Client].&[4] ON 0 FROM" +
" (SELECT [DimTime].[CalenderDayHour].[CalenderDayHour].&[2013010100]:"+
"[DimTime].[CalenderDayHour].[CalenderDayHour].&[2013121216] ON 0 FROM [247OLAP]))");
When I run this code I get the following exception at executeOlapQuery line-
Exception in thread "main" java.lang.RuntimeException: [FATAL]:1:1: Content is not allowed in prolog.
at org.olap4j.driver.xmla.XmlaOlap4jUtil.checkForParseError(XmlaOlap4jUtil.java:134)
at org.olap4j.driver.xmla.XmlaOlap4jUtil.parse(XmlaOlap4jUtil.java:83)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:884)
at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getMetadata(XmlaOlap4jDatabaseMetaData.java:137)
at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getMetadata(XmlaOlap4jDatabaseMetaData.java:67)
at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getDatabaseProperties(XmlaOlap4jDatabaseMetaData.java:1044)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.makeConnectionPropertyList(XmlaOlap4jConnection.java:324)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.generateRequest(XmlaOlap4jConnection.java:1037)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:849)
at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:136)
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:90)
at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:116)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapDatabase(XmlaOlap4jConnection.java:451)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapCatalog(XmlaOlap4jConnection.java:501)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getCatalog(XmlaOlap4jConnection.java:496)
at org.olap4j.driver.xmla.XmlaOlap4jStatement.executeOlapQuery(XmlaOlap4jStatement.java:291)
at com.tfsc.ilabs.olap4j.POC.main(POC.java:28)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.olap4j.driver.xmla.XmlaOlap4jUtil.parse(XmlaOlap4jUtil.java:80)
Any help will be much appreciated.
You should check what's being sent back by the server, using WireShark or something similar. This kind of error happens when the XML parser tries to parse the response it got. The server is probably not sending XML content back.

active directory filter with objectGUID encoded as specified in rfc2254 doesn't work

I'm using java ldap to access active directory, more specifically spring ldap.
a group search by objectGUID yields no results when the filter is encoded as specified in rfc2254.
this is the guid in its hex representation:
\49\00\f2\58\1e\93\69\4b\ba\5f\8b\86\54\e9\d8\e9
spring ldap encodes the filter like that:
(&(objectClass=group)(objectGUID=\5c49\5c00\5cf2\5c58\5c1e\5c93\5c69\5c4b\5cba\5c5f\5c8b\5c86\5c54\5ce9\5cd8\5ce9))
as mentioned in rfc2254 and in microsoft technet:
the character must be encoded as the backslash '' character (ASCII
0x5c) followed by the two hexadecimal digits representing the ASCII
value of the encoded character. The case of the two hexadecimal
digits is not significant.
Blockquote
so a backslash should be '\5c'
but I get no results with above filter from AD. also if I put that filter in AD management console custom filters it does not work.
when I remove the 5c from the filter it works both from java and in AD console.
Am I missing something here?
of course I can encode the filter without the 5c but I'm nt sure it the right way and I prefer to let spring encode the filters because it knows a lot of things that I should do manually.
I think the blog entry at:http://www.developerscrappad.com/1109/windows/active-directory/java-ldap-jndi-2-ways-of-decoding-and-using-the-objectguid-from-windows-active-directory/ provides the information you need.
i found solution with php to get user with objectGUID
etap one when i create user i put his objectGuid in bdd, the objectGuid that you see in the Ad ex $guid_str = "31207E1C-D81C-4401-8356-33FEF9C8A"
after i create my own function to transform this object id int hexadécimal
function guidToHex($guid_str){
$str_g= explode('-',$guid_str);
$str_g[0] = strrev($str_g[0]);
$str_g[1] = strrev($str_g[1]);
$str_g[2] = strrev($str_g[2]);
$retour = '\\';
$strrev = 0;
foreach($str_g as $str){
for($i=0;$i < strlen($str)+2; $i++){
if($strrev < 3)
$retour .= strrev(substr($str,0,2)).'\\' ;
else
$retour .= substr($str,0,2).'\\' ;
$str = substr($str,2);
}
if($strrev < 3)
$retour .= strrev($str);
else
$retour .= $str ;
$strrev++;
}
return $retour;
}
this function return me a string like \1C\7E\20\31\1C\D8\01\44\83\EF\9C\8A"\F9\ED\C2\7F after this i put this string in my filter and i get the user
#
to get format of objectGuid
i use this fonction that i foud it in internet
function convertBinToMSSQLGuid($binguid)
{
$unpacked = unpack('Va/v2b/n2c/Nd', $binguid);
return sprintf('%08X-%04X-%04X-%04X-%04X%08X', $unpacked['a'], $unpacked['b1'], $unpacked['b2'], $unpacked['c1'], $unpacked['c2'], $unpacked['d']);
}
i mean this format = 31207E1C-D81C-4401-8356-33FEF9C8A
Pass a byte array and search should work.

WPF string escaping - Exception is thrown while creating control template

I am trying to construct a Control template from code behind. Things were working fine till recently I found that the code was throwing an exception because of escape characters in string. The error message is dynamically constructed by retrieving from resource file.
The exception is
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Name cannot begin with the '#' character, hexadecimal value 0x40. Line 1, position 537.
//In this case when exception is thrown,
//string errorMessage = "Name cannot contain any of the following characters $ \" # ; ^ | "
public static ControlTemplate GetErrorTemplate(string errorMessage)
{
string xamlString = "<ControlTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" " +
"xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" " +
"xmlns:nicefx=\"clr-namespace:NiceFx.Interop.UIComponents;assembly=NiceFx\" " +
"xmlns:wpfkit=\"http://schemas.microsoft.com/wpf/2008/toolkit\" >" +
" <DockPanel LastChildFill=\"True\">" +
"<TextBlock Foreground=\"White\" Background=\"Red\" FontSize=\"12\" Padding=\"2\" FontFamily=\"Trebuchet MS\" Margin=\"5,5,0,0\" TextWrapping=\"Wrap\" DockPanel.Dock=\"Bottom\" Text=\"" + errorMessage + "\"></TextBlock>" +
"<AdornedElementPlaceholder />" +
" </DockPanel>" +
" </ControlTemplate>";
//EXCEPTION OCCURS IN THIS LINE
ControlTemplate ct = (ControlTemplate)XamlReader.Load(XmlReader.Create(
new StringReader(xamlString)));
return ct;
}
How do I escape this string? I tried all possible ways but I am unable to do so.
According to the comment in your code, errorMessage contains a ", which will be inserted (without escaping it) into the XAML you are constructing. This " will then act as the closing quote of the Text attribute. At this point, the next non-whitespace character the parser encounters will be #, which is not an allowed character for the name of a XAML attribute, so it stops and reports the error.
That covers the why. As for how to escape it, you can use the XML entity for double quote: " Note that you may need to apply this escaping to multiple characters in your parameter.

How to receive variables in a post in google app engine that contains string with chars like: õ á?

email = self.request.get('email')
name = self.request.get('name')
mail.send_mail(sender="myemail", email=email, body=name, subject="sss " + name + "sdafsaã")
// added ã: the problem was that "sdafsaã" should be u"sdafsaã". with a "u" before the string. and now it works
then i get this
main.py", line 85, in post
subject="sss " + name + "sdafsa",
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 36: ordinal not in range(128)
the might have chars like õ ó and something like that.
for more details:
the code to run the worker(the code before)
the name is the one that is received from the datastore and contains chars like õ and ó...
taskqueue.add(url='/emailworker', params={'email': e.email, 'name': e.name})
thanks
Try reading a little about how unicode works in Python:
Dive Into Python - Unicode
Unicode In Python, Completely Demystified
Also, make sure you're running Python 2.5 if you are seeing this error on the development server.
You should use:
email = self.request.get('email')
name = self.request.get('name')
mail.send_mail(sender="myemail",
email=email,
body=name,
subject="hello " + name.encode('utf-8') + " user!")
The variable name is a unicode string and should encoded in utf-8 or in the kind of encode you are using in you web application before concatenating to other byte strings.
Without name.encode(), Python uses the default 7 bits ascii codec that can't encode that specific character.
the problem is joining 2 strings: ||| body = name + "ã" => error ||| body = name + u"ã" => works!!! |||
Try with encode
t ='việt ứng '
m = MyModel()
m.data = t.encode('utf-8')
m.put() #success!

Resources