ericaddison / APT_miniProject_Android

The Android App for Connexus
0 stars 0 forks source link

Query a single streamID: How to set QueryParamater using "requestStreamInfoData"? #11

Open mspagon opened 6 years ago

mspagon commented 6 years ago

I want to query information on a single streamID:

So I created a List with one streamID in it and passed it to requestStreamInfoData(...) and it generates the following URL:

http://apt17-miniproj-whiteteam.appspot.com/services/streaminfo?searchString=%5B%225631383682678784%22%5D

But it returns a JSON of everything in the database.

How can I set "searchString" within the URL to be streamID?

I basically want to generate the following request:

https://apt17-miniproj-whiteteam.appspot.com/services/streaminfo?streamID=5631383682678784

    public void requestStreamInfoData(List<String> streamIDs, ServerResponseAction callbackAction){

        JSONArray arr = new JSONArray(streamIDs);

        Uri.Builder uri = getBaseServicesUri();
        uri.appendPath(mContext.getString(R.string.url_service_streaminfo))
                .appendQueryParameter(mContext.getString(**R.string.url_parm_search_term**), arr.toString());
        String myUrl = uri.build().toString();

        Log.v("WHAT IS THE URL?: ", myUrl);

        doRequest(myUrl, callbackAction);
    }
mspagon commented 6 years ago

Also, why does the server communicator constructor take a View as an argument?

psigourney commented 6 years ago

For some reason EVERYTHING in android wants a View as an argument.

mspagon commented 6 years ago

Temporary resolution:

Creating my own requestSingleStreamInfo method for the time being.

psigourney commented 6 years ago

Ohhh... I see what you're saying.... one sec.... if 'arr' is your long variable containing the streamID:

long arr = 2230857230862068;

uri.appendPath(mContext.getString(R.string.url_service_streaminfo))
                .appendQueryParameter("streamID", arr.toString());

First field is the name of the parameter, second field is the value

Here's what I did in ServerCommunicator for the ViewAStream page to return all the items for a single stream:

    public void requestStreamItemInfoData(long streamID, ServerResponseAction callbackAction){

        Uri.Builder uri = getBaseServicesUri();
        uri.appendPath(mContext.getString(R.string.url_service_streamiteminfo));
        uri.appendQueryParameter("streamid", Long.toString(streamID));
        String myUrl = uri.build().toString();
        doRequest(myUrl, callbackAction);
}

Then call the function with:

comm.requestStreamItemInfoData(longStreamID, new ServerResponseAction()

ericaddison commented 6 years ago

hey guys Here are a few comments :)

mspagon commented 6 years ago

Solved - Long numbers are Suffixed with "L".

Ugh... I'm going to keep using my method that uses a string type for StreamID for the time being.

image

Edit: changed it to a constructor... still an issue??

image

Edit: Looks okay with a String?

image