2

I'm trying to query a Dynamic-CRM system using FetchXML get request. The error: "Invalid Uri: The Uri scheme is too long. UriFormatException" occurs when I'm using specific attributtes\filters. For example: When trying to use filter condition with "on-or-after" operator referring dateTime with time stamp. I'm getting:

The initial query is big and working, but event when I shorten the query and use a specific attribute, the error raise. I couldn't put my finger on the problem. See my code, as example: This is not working:

<filter>
  <condition attribute="scheduledend" operator="le" value="2020-03-16T10:23:30" />
</filter>

This is working, but witout time stamp:

<filter>
  <condition attribute="scheduledend" operator="on-or-before" value="03/16/2020" />
</filter> 

Let me emphasize - The

<filter>
  <condition attribute="scheduledend" operator="le" value="2020-03-16T10:23:30" />
</filter>

might work if I remove some query attributes or filters - so this is just an example - I couldn't find a pattern for working\not working. What might be the root cause for this problem ?

Guy E
  • 1,775
  • 2
  • 27
  • 55
  • 1
    I found the exact same strange and seemingly random problem, where once the parameters were over a certain length, colons in values would break the request and cause this error. What an odd bug! This thread saved me. Ta!! – underscore_d Jun 11 '22 at 09:45

1 Answers1

6

It strikes me that since the colon : is a normal part of an HTTP URI, the colons in the timestamp may be triggering the issue. According to the standard URL encoding, : encodes to %3A. Maybe give that a shot.

Another consideration is that a single quote is a legal URL character but a double quote is unsafe, so maybe switch to single quotes inside the FetchXML:

<condition attribute='scheduledend' operator='le' value='2020-03-16T10%3A23%3A30' />

Aron
  • 3,877
  • 3
  • 14
  • 21
  • I found the exact same strange and seemingly random problem, where once the parameters were over a certain length, colons in values would break the request and cause this error. What an odd bug! This thread saved me. Thanks for such a good, correct guess! URL-encoding the colons resolved my problem too. – underscore_d Jun 11 '22 at 09:46