Nick7420609
Posts: 0
Joined: Sun Mar 08, 2015 6:00 pm

ajax calls remove "?" from request

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

ajax calls remove "?" from request

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.

Nick7420609
Posts: 0
Joined: Sun Mar 08, 2015 6:00 pm

ajax calls remove "?" from request

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!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

ajax calls remove "?" from request

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.

Return to “Issues”