Assign Message Set Path does not work, could we remove the tag if not working?

Hi, I was in the need to dynamically set the PATH of my target url rest call.

I ended up doing that in javascript. I noticed when I tried to use SET Path in Assign Message Policy I got into very very weird errors and couldnt repair my api. I had to delete and start again.

Error was something super technical like message flow exist but not deployed or something like that.

then I opened the documentation of Assign Message and it says specifically to not user SET PATH cause it doesnt work.

is it possible to remove the feature if its not working ? or in what case I could use that setter ?

0 9 1,292
9 REPLIES 9

I'm sorry you're having trouble. The "couldn't repair my api" thing sounds like it was unpleasant.

I opened the documentation of AssignMessage and it says specifically to not use SET PATH cause it doesn't work.

I'm not aware of any such documentation. Please cite a link where you found this statement. A verbatim text copy/paste would help, and a screenshot would also help.

@Dino-at-GoogleHi, actually the doc says "works for Service Callout not for target.url. so I was trying to use it the wrong way. (target url).

https://docs.apigee.com/api-platform/reference/policies/assign-message-policy#setelement-setpathelem...

It just makes me think that that should be the default scenario, since normally you create an API to have a target URL not to have a Service Callout.

Esteban, I understand. You have a good point.

I'm glad you got things sorted out.

@dchiesa1 

Here on Apigee X documentation it says that "This element isn't currently working as designed to override/rewrite a proxy's target URL" .

Here "this element" refers to <Path>.

If we have to set the target.url via Javascript or AM policy like below

<AssignMessage name="Assign-Message-1">
...
  <AssignVariable>
    <Name>target.url</Name>
    <Value>http://mocktarget.apigee.net/user?user=Dude</Value>
  </AssignVariable>
...


Then are we not hardcoding the hostname here?

I wish to use Target Server to avoid hardcoding the entire URL to the env variable 'target.url'.

Can you please suggest a way or a workaround to set the path of the target endpoint?

Please advise.

@dchiesa1 

It kind of solves the issue but not completely

Below is the config I have

Target Endpoint HTTP Config

 

<HTTPTargetConnection>
        <SSLInfo>
            <Enabled>true</Enabled>
            <IgnoreValidationErrors>true</IgnoreValidationErrors>
        </SSLInfo>
        <LoadBalancer>
            <Server name="MyTargetServer"/>
        </LoadBalancer>
        <Path>{targetBasePath}</Path>
    </HTTPTargetConnection>

 

 

And in the Target Request Pre-Flow, i have an AM policy to set the basepath

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="AM-SetTargetRquest">
    <DisplayName>AM-SetTargetRquest</DisplayName>
    <Properties/>
    <Set>
        <Headers>
            <Header name="Content-Type">application/json</Header>
        </Headers>
        <QueryParams>
            <QueryParam name="name">{name}</QueryParam>
            <QueryParam name="email">{email}</QueryParam>
        </QueryParams>
        <FormParams/>
        <Verb>GET</Verb>
    </Set>
    <AssignVariable>
        <Name>targetBasePath</Name>
        <Value>/api/v1/transaction/dnd</Value>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

 


So now my backend call being called is coming as
https://mydomain.com/api/v1/transaction/dnd/customersearch?name=Dino&email=xyz@abc.com

Instead of
https://mydomain.com/api/v1/transaction/dnd?name=Dino&email=xyz@abc.com

The proxy pathsuffix ("/customersearch") seems to get appended to the path.

How can I avoid this?

Please advise.

<AssignMessage name='AM-SuppressCopyPathSuffix'>
  <AssignVariable>
    <Name>target.copy.pathsuffix</Name>
    <Value>false</Value>
  </AssignVariable>
</AssignMessage>

I kinda wish the model allowed for that capability to be present as a configuration element in the Targetendpoint, but ... it's not. So you set a context variable and the target endpoint logic reads that and doesn't append the pathsuffix.

This worked!
Thanks a ton @dchiesa1 

Can we add a request to engineering to add such feature?