« Back to full topics list
0
0

I need to replicate functionality from an existing api that has a dynamic url. It grabs a device id. How can I do this with scriptr? Can I convert part of a url to params somehow?

ANSWERED
Marked as spam
Posted by - Asked on July 13, 2017 1:19 pm - 34 views

1 Replies

1
Private reply

Hi Stefan,

I believe you are describing a URL of the form http://api.scriptrapps.io/myScript/deviceId. If this is the case, you can definitely do that from myScript where you can grab the deviceId using request.pathInfo.

Check out the Creating RESTful APIs with Scriptr.io section of the documentation for more on this (https://www.scriptr.io/documentation#documentation-restfulapisCreatingRESTfulAPIswithScriptr.io).

Hope this helps,

Julien Mrad
Scriptr.io Support

Marked as spam
Posted by - Replied on July 13, 2017 2:59 pm

This is exactly what I’m looking for Julien. Thank you.

( at July 13, 2017 2:00 pm)

When utilizing the GET strategy, parameter names and their esteems get submitted on the URL string after a question mark. Distinctive parameter name/esteem sets are isolated by ampersands. The following is an example of submitting two parameters to the \’my-demo-servlet\’ servletW. The primary parameter is called \’param1\’ and has an estimation of \’hi\’, and the second parameter is called \’param2\’ and has an estimation of \’farewell\’.

localhost:8080/demo/my-demo-servlet?param1=hello&param2=goodbye

Be that as it may, what happens if the parameter esteem in the URL string has a space or some other extraordinary character? Presenting a HTMLW frame will bring about uncommon characters being consequently changed over to exceptional codes for us. Nonetheless, now and again it is important to encode these characters without the guide of a HTML frame. JavaSW has a class called URLEncoder that can encode these characters so they are legitimately dealt with. The encode strategy takes two parameters, the string to be encoded and the encoding plan. Unless you\’re smoking rocks, you most likely need the encoding plan to be \”UTF-8\”.

Delorish
writer@ https://essayservices.org/

( at April 24, 2018 4:32 am)