Getting Error "protocol.http.EmptyPath" when trying to set target.url for multiple TargetEndpoints

Not applicable

I have 3 different TargetEndpoints. In all the TargetEndpoint PreFlow Requests when i am trying to set target.url(tried using both Javascript and AssignMessage) the policy is executed successfully but after that the request is not sent to any target and Apigee is throwing the below Error.

{     
	"fault": 
	{         
		"faultstring": "protocol.http.EmptyPath",         
		"detail": 
		{             
			"errorcode": "protocol.http.EmptyPath"         
		}
	} 
}

AssignMessage code used to set the target.url:

<AssignVariable> 
	<Name>target.copy.pathsuffix</Name>         
	<Value>false</Value>
</AssignVariable>
<AssignVariable>
	<Name>target.url</Name>
	<Value>http://apigee.com</Value>
</AssignVariable>

I observed that I am getting this error only when I am trying to override the target.url. When I remove the AssignVariable tag containing target.url from above code then the request is being sent to the default TargetEndpoint fine.

I tried this approach for another API and it worked fine. The only difference between that API and this one is that this API has 3 TargetEndPoints and the other one has only 1 default TargetEndpoint. So I am guessing this is related to this some how.

I am trying this in OnPremise not cloud if it helps.

Help is appreciated.

0 5 1,458
5 REPLIES 5

Not applicable

Hello @Sumnath,

I am not sure how we are managing calling of differenr target servers, but we should use something similar as:

<RouteRule name="ABCD">

<Condition>(proxy.pathsuffix = "/abcd" and REQUEST_VERB ="GET")</Condition> <TargetEndpoint>abcd</TargetEndpoint>

</RouteRule>

<RouteRule name="DEF">

<Condition>(proxy.pathsuffix = "/def" and REQUEST_VERB ="POST")</Condition> <TargetEndpoint>def</TargetEndpoint>

</RouteRule>

And we should have different targetservers (containing different IP and Port for each backends) for "ABCD" or "DEF".

Does it help ?

Hi Meghdeep,

I am actually calling the different target servers the same as you mentioned above.

And I also gave gave different URL's( IP and Port) for each TargetEndpoint when I created them.

The problem is I am trying to change the target url(entire url not just path) of one of the target server and when ever I try to set target.url with the new url apigee is throwing the above mentioned error. Error is not thrown at the policy I am setting target.url and I could see in trace that target.url is set to new URL but after that policy is executed Apigee is throwing the error protocol.http.EmptyPath. Never came across this error before and couldn't find anything regarding it.

Hello @Sumnath,

Are you trying to assign the value of IP and PORT of the target server in a flow variable and then trying to set these variables in the TargetServer call ?

Not applicable

Hello @Sumnath,

Are you trying to assign the value of IP and PORT of the target server in a flow variable and then trying to set these variables in the TargetServer call ?

I encountered same issue.Below is the TargetEndPoint setting where rewriteTargetUrl is a javascript code to do target.url setting.

<TargetEndpoint name="default">
    <Description/>
    <FaultRules/>
    <Flows>
        <Flow name="defaultflow">
            <Request>
                <Step>
                    <Name>rewriteTargetUrl</Name>
                </Step>
            </Request>
        </Flow>
    </Flows>
    <PreFlow/>
    <HTTPTargetConnection>
        <Properties/>
        <URL>http://mocktarget.apigee.net</URL>
        <Path>http://mocktarget.apigee.net</Path>
    </HTTPTargetConnection>
</TargetEndpoint>


javascript for rewriteTargetUrl
if(context.flow=="TARGET_REQ_FLOW"){
    context.setVariable('target.url', 'https://www.bing.com');
    context.setVariable('mypath', 'https://www.bing.com');
}


Proxy setting:
<ProxyEndpoint name="default">
    <HTTPProxyConnection>
        <BasePath>/service/v1/</BasePath>
        <VirtualHost>default</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="DefaultRoute">
        <TargetEndpoint>default</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>


I used "trace" and can see the "mypath" and "target.url" being set as expected in Javascript output. But right after that is like in the screenshot.