How can I pass multiple parameters to an Ensemble REST service and return an authorization token as a response JSON message
This question came on the Ensemble in Healthcare email list. It's a great question. I'm working on an answer, but am posting it here to get any other input. I'll also address the option of using %CSP.REST.
Hello everyone,
Using Intersystems Healthshare/Ensemble, I am trying to make a RESTful Interface between Android/iOS app and Cache database. I have some queries and I am unable to find where exactly I can get any resources on them.
1. By extending the EnsLib.REST.Service class, I have so far made some basic methods like if the interface receives and email ID via a GET request, it checks if its exists in the database and pulls out the password for the account. However, I want to know if we can send back some sort of authorization token or api key as part of the JSON response packet, as a way of notifying the user that his account is authenticated? Also, the key or token will be stored in the mobile cache and used for further calls from the app.
2. Till now, to test the service I so far developed, I am calling the interface by a URL as follows -
http://localhost:57772/myDemo/myService/myApp/UserAccounts/abc@gmail.com
But as you can see I am able to pass only one parameter (which is the email ID at last). I wanted to ask what if I have multiple parameters?
I guess I can restructure the URL something like this ->
http://localhost:57772/myDemo/myService/myApp/UserAccounts/:emailID/:password/:signInType/:socialNetID
But is there any alternative to this? For example, what if I want to receive a JSON request packet (which will have these parameters) and then parse it to extract these parameters and then call my service appropriately? Can this be done?
3. I want to provide this basic interface to the app developers, just for testing purposes. I want to know if there exists some kind of testing environment, so that I can share the URL with developers and they can make the calls to test it. The developers would be accessing the interface remotely (not from the same network which I am connected to).
Any help would be appreciated. Thanks!