Page 1 of 1

ajax calls remove "?" from request

Posted: Tue Mar 10, 2015 7:02 pm
by Nick7420609

I'm trying to make a ajax call using Appery's rest service through proxy, however the URL that it generates is not valid for the receiver :

Appery's generated URL : http://hostname/my_api?username=foo

but I need the URL to have no "?" and be such as :

http://hostname/my_api/foo

Please note, no "username" and "?" are needed and argument must be passed after a "/"

How can I achieve this?

Thanks


ajax calls remove "?" from request

Posted: Fri Mar 13, 2015 5:13 am
by Yurii Orishchuk

HI Nick

For this goal you can make following:

  1. Use in service URL:

    pre

    http://hostname/my_api/{userName}

    /pre

  2. Navigate to "request" tab and "Query string" sub tab. Add "userName" request parameter.

  3. Use this "userName" request parameter in mapping to pass needed value.

    More info here: http://devcenter.appery.io/documentat...

    Regards.


ajax calls remove "?" from request

Posted: Tue Mar 24, 2015 9:44 pm
by Nick7420609

Hi Yurii,

Thank you very much for the details. I've tried taking this approach, and it works if I add the {userName} in query string and adding a default value during the "test", however I'm having trouble passing the parameter, as it's not clear or even mentioned on the document, how to actually pass a dynamic value:

"where the some_id would be set when the service is invoked."

What's the proper way to pass a value that is saved in a local storage, to invoke a service?

Thanks!


ajax calls remove "?" from request

Posted: Fri Mar 27, 2015 4:22 am
by Yurii Orishchuk

Hi Nick,

Here is how you can do it:

  1. put service on the page(data tab).

  2. click "before send" mapping.

  3. find your goal parameter in request parameter.

  4. click "JS" to put JS code.

  5. populate it with following JS code:

    pre

    //where "someLSVname" is your local storage variable.
    return localStorage.getItem("someLSVname");

    /pre

    Regards.