'Azure APIM pass through request querystring to backend completely

On Azure APIM I have an operation that has querystring parameters. In the policy I change the backend url and apply a rewrite-uri to alter the url. Only the querystring from the caller is not applied to the backend.

Is it possible to passthrough the incoming querystring directly to the backend without changing anything?

<inbound>
    <base />
    <set-backend-service base-url="https://api.test.eu" />
    <rewrite-uri template="dispatch/gateway/test" />
</inbound>

UPDATE

Fixed by using the folloing:

<set-backend-service base-url="https://api.test.eu" />
<rewrite-uri template="/dispatch/gateway/test" copy-unmatched-params="true" />


Solution 1:[1]

You actually have 4 items variables in your code, each one with a very limited scope (only the code-block of the respective if).

Instead you'll want to create one variable with a bigger scope:

if (i == 0) { 
            final CharSequence[] items;
            if (j == 0) { 
                items = new CharSequence[] {"4:45", "5:00"};
            } else if (j == 1) { 
                items = new CharSequence[] {"4:43", "4:58"};
            } else if (j == 2) { 
                items = new CharSequence[] {"4:41", "4:56"};
            } else { 
                items = new CharSequence[] {"4:38", "4:53"};
            }
            // you can use items here
}

Edit: I forgot that the new CharSequence[] is necessary here. You can leave it out if you initialize the variable during declaration, but here you moved the declaration out and use a simple assignment to set a value. For some reason the short syntax of defining an array is only valid in an initializaton statement (i.e. in an assignment that is in the same statement as the declaration).

Solution 2:[2]

In Java you have strict block-level scope, so for example:

if (blah) { int foo = 1; }
// foo is no longer visible here

So once you reach that closing curly brace } your items variable is no longer visible. This is different from JavaScript for example where you have function-level scope.

Hope this helps.

Solution 3:[3]

Because you define (as well as give a value to) items within a block, it is only visible within that block. Pull the definition out of the block to somewhere visible to both the snippets you have given us, and just assign a value within the if else construct.

Solution 4:[4]

Declare items before the

if (i == 0) {

The way you are doing it now, items is only in scope inside you inner ifs.

Solution 5:[5]

You are only declaring items in local scope. You need to move the

final CharSequence[] items

outside the if clauses and the instantiate it inside the if clause.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joachim Sauer
Solution 2 greim
Solution 3 AakashM
Solution 4 Thomas Lötzer
Solution 5 Robby Pond