Search code examples
dynamics-crmpostmanfetchxml

Invalid Uri: The Uri scheme is too long. UriFormatException" In dynamics-CRM FetchXML


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 ?


Solution

  • 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' />