Unable to set queryparams and target.url in the same AssignMessage policy.

Tried setting up the query params and target.url in the same AssignMessage policy. Attached the policy to target endpoint preflow. But I do not see the query params in the trace tool. Any thoughts?

@Dino-at-Google @Siddharth Barahalikar

10171-tracetool-am.png

?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
    <DisplayName>Assign Message-1</DisplayName>
    <Properties/>
    <Set>
        <QueryParams>
            <QueryParam name="code">wertyy</QueryParam>
        </QueryParams>
    </Set>
    <AssignVariable>
        <Name>target.url</Name>
        <!--<Value>http://abc.com/user?user=Dude</Value>-->
        <Ref>url</Ref>
    </AssignVariable>
    <AssignVariable>
        <Name>target.copy.pathsuffix</Name>
        <Value>true</Value>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
0 2 332
2 REPLIES 2

The problem is that setting target.url overrides the URL that would be constructed from the QueryParams and Path and other elements.

You seem to want to set the scheme and host, and ALSO the path and query params. You can use the QueryParams and Path elements for the latter, but not when you also set the scheme and host. Try this to get what you want?

<AssignMessage name="AM-1">
  <!--
    <Set>
        <QueryParams>
            <QueryParam name="code">wertyy</QueryParam>
        </QueryParams>
    </Set>
  -->

    <AssignVariable>
      <Name>myurl</Name>
      <Value>https://myapp.example.com/</Value>
    </AssignVariable>

    <AssignVariable>
      <Name>qparam_code</Name>
      <Value>qwerty</Value>
    </AssignVariable>

    <!--
    <AssignVariable>
        <Name>target.url</Name>
        <Ref>myurl</Ref>
    </AssignVariable>
    -->

    <AssignVariable>
        <Name>target.url</Name>
        <Template>{myurl}?code={qparam_code}</Template>
    </AssignVariable>

    <AssignVariable>
        <Name>target.copy.pathsuffix</Name>
        <Value>true</Value>
    </AssignVariable>

    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

    <AssignTo>request</AssignTo>

</AssignMessage>


Not applicable

you can use one assign-message to copy the pathsuffix to a variable in the request of proxy endpoint and in a javascript, in target preflow you can set target url

?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
    <DisplayName>Assign Message-1</DisplayName>
   
    <AssignVariable>
        <Name>my-pathsuffix</Name>
	<Ref>proxy.pathsuffix</Ref>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
var final_url = "http://abc.com/use" + context.getVariable("my-pathsuffix") + "?code=wertyy";

context.setVaribale("target.url", final_url);