using the AssignMessage policy to remove Query params vs Form Params

what is the difference between <QueryParams> and <FormParam>
I'm trying to remove a paramter from a request sent by developer apps. The url is - https://rohitreddykancharla9030-eval-test.apigee.net/assign-message-remove?
Now when I make a request from postman there we can select many params, auth, headers, body and so on. If I select PARAMS and in params add the key:value paris, policy is not removing the "foo" paramter from the request (url after adding key:value pairs = https://rohitreddykancharla9030-eval-test.apigee.net/assign-message-remove?hello=world&foo=bar) output is as follows "args": { "foo": "bar", "hello": "world" }, Like we can see foo paramter is not removed.
But if I send the post request from postman BODY "foo" parameter is removed output is as follows "args": {}, "data": "", "files": {}, "form": { "hello": "world" },

IF I use params in postman and <QueryParam> in the code "Foo" is removed and output is "args": {}, "data": "", "files": {}, "form": { "hello": "world" },

Question is what is difference between <QueryParams> and <FormParam>


CODE:

<?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/>
    <Remove>
        <FormParams>
            <FormParam name="foo"/>
        </FormParams>
        <!--  <QueryParams>-->
        <!--    <QueryParam name="foo"/>-->
        <!--</QueryParams>-->
    </Remove>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

0 4 662
4 REPLIES 4

Query and Form parameters are defined in HTTP. They are general, and not specific to Apigee.

See here for some prior discussion.

  • A query parameter appears in the URL, following the ?

    for example, consider this URL: http://example.com/v1/collection?abc=def

    The uri path is /v1/collection

    there is a single query parameter, called abc. Its value is def.

    Any HTTP request, any verb, can pass Query parameters. It's just a matter of appending to the URL.

  • In contrast, a form parameter is passed in the body of a POST, when content-type is application/x-www-form-urlencoded.

    Often in REST APIs we think of POST bodies containing application/json, which looks like this:

    {  "foo" : "bar123", "something" : true }
    	

    But a POST body with application/x-www-form-urlencoded looks like this:

    foo=bar123&something=true
    	

    A form parameter can be passed only with a POST verb. (maybe with PUT, I am not sure about that).


The AssignMessage policy can set or remove either Query parameters, or Form Parameters, or both.

I am not clear what you are doing with Postman. I know that within Postman it is possible for you to specify both Query params and Form parameters. If you are using AssignMessage / Remove and you specify QueryParams, it will remove the named parameters from the URL, if they exist. If you are using AssignMessage / Remove and you specify FormParams, then it will remove the named parameters from the POST body, if they exist, and if the content-type is application/x-www-form-urlencoded .

Using postman I'm making POST request to my proxy
In postman we can send many forms of parameters - (Refer Image)

10999-apigee.png

Now if I add key and value form PARAMS shown in the image and used <QueryParam> in the policy paramters are removed else NOT (certainly not if I use <FormParam>) .

when I tried using BODY - > x-ww-form-urlencoded as shown in the image and <FormParam> assignMessage policy is removing the paramters.

Why is that ?

Now, what is the difference between <QueryParam> and <FormParam>

In which scenarios we need to use <QueryParam>

In which scenarios we need to use <FormParam>

what is the difference between <QueryParam> and <FormParam>

You'll need to Google that.

See:

https://en.wikipedia.org/wiki/Query_string

https://en.wikipedia.org/wiki/POST_(HTTP)#Use_for_submitting_web_forms

Not applicable

query parama are the query parameters and passed in the url.

http://xyz.com/v1/xyz?a=10&b=20&c=mnop

Normally your url with queryparams look as above. After ? All the things are part of queryparams.

You can have multiple query parameters appended with &

Your queryparams should not hold username or password or any private information. This can be seen easily.

In Apigee you can get these as request.queryparam.variablename.

Eg. request.queryparam.a

Form parameters are a type of body in case of REST. These are normally configured when your content type is application/x-www-form-urlencoded.

You can get the formparam in Apigee as below.

request.formparam.variablename

You can see these in postman easily.