How to read extracted variables in target point url ?

Not applicable

Hi All,

I have a target URL as below in my app, which takes firstName and lastName as below,

/createUser/firstName/:firstName/lastName/:lastName

I used the QueryParameters in the Extract Variable policy to read the firstName and lastName values from URL, its working.

Now in targetEndpoint i used the above URL as,

<HTTPTargetConnection>
        <Properties/>
        <URL>http://<myhost>/createUser/firstName/:firstName/lastName/:lastName</URL>
    </HTTPTargetConnection>

Now, how can i tell apigee to put the extracted values of firstName and lastName in extract variable policy. I am unable to pass those values in the target URL above.

Thanks for your help in advance.

0 4 209
4 REPLIES 4

The easiest way is to leave the basepath as /createUser as well as the target to end at /createUser

By default the platform will append paths and query parameters to the request that goes to the target.

Now, trying to not be nitpicking and to not hijack the thread, but the design of the API itself would be better if you had something along the lines of:

POST /users

{

"firstName": "...",

"lastName": "...",

...

}

And in your response it would return a unique id to the user that could be referenced to GET it as /users/{userId}

So, what you want to say is that i should write target url as,

<URL>http://<myhost>/createUser</URL>

instead of,

<URL>http://<myhost>/createUser/firstName/:firstName/lastName/:lastName</URL>

correct, anything that you append beyond your basepath will be added to the target

for example:

basepath /createUser

request /createUser/firstName/John/lastName/Smith

target will be: /createUser/firstName/John/lastName/Smith

Thanks Ricardo, this worked like a charm for me....