Is there a way to prevent the collapsing of path expressions?

Not applicable

Empty uri elements http://mysite.org/test/////something being truncated to http://mysite.org/test/something

Is there a way to prevent this?

We have a specific use case (argh!) where the client application is already set up to make calls like this:

http://mysite.org/test/1/2/3/4/somepath

Additionally - they are currently able to - and actively do make calls to the same somepath resource - but with no data in the 1, 2, 3, 4 spots:

http://mysite.org/test/////somepath

of course this is getting translated to:

http://mysite.org/test/somepath - im betting at the router (this is just my bet.. im not 100% sure which is why im here asking!)

1 2 91
2 REPLIES 2

Maybe.

I suppose you are talking about assigning a path, using variables. You used the phrase "empty URI elements", and I'm inferring by that, you mean that the variables you're using are not assigned, or are empty. (If my assumptions are not valid, then the rest of this response won't be useful)

There's a way to allow a variable reference to resolve to a 'default value'. For example, suppose you're using the ServiceCallout policy to set a URL for the target. It would look something like this:

<ServiceCallout name='SC-1'>
  <Request variable='authenticationRequest'>
    <Set>
      <Payload contentType='application/json'
        variablePrefix='%' variableSuffix='#'><![CDATA[{
 "grant_type":"client_credentials", "client_id":"whatever", "client_secret":"something-secret"
}]]></Payload>
       <Verb>POST</Verb>
       <Path>/token</Path>
    </Set>
  </Request>
  <Response>tokenResponse</Response>
  <HTTPTargetConnection>
    <Properties>
      <Property name='success.codes'>2xx, 4xx, 5xx</Property>
    </Properties>
    <URL>https://api.usergrid.com/{target_org}/{target_app}</URL>
  </HTTPTargetConnection>
</ServiceCallout>

If the variables target_org or target_app are empty, then the URL will resolve to https://api.usergrid.com//

But if you'd like a default value, then you could do this:

<ServiceCallout name='SC-1'>
  <Request variable='authenticationRequest'>
    <Set>
      <Payload contentType='application/json'
        variablePrefix='%' variableSuffix='#'><![CDATA[{
 "grant_type":"client_credentials", "client_id":"whatever", "client_secret":"something-secret"
}]]></Payload>
       <Verb>POST</Verb>
       <Path>/token</Path>
    </Set>
  </Request>
  <Response>tokenResponse</Response>
  <HTTPTargetConnection>
    <Properties>
      <Property name='success.codes'>2xx, 4xx, 5xx</Property>
    </Properties>
    <URL>https://api.usergrid.com/{target_org:unknown}/{target_app:unknown}</URL>
  </HTTPTargetConnection>
</ServiceCallout>

In this case, if the variables target_org or target_app are empty, then the URL will resolve to https://api.usergrid.com/unknown/unknown

so this will actually be REALLY useful for another problem... let me expand on the question a bit..