Skip to content

Commit

Permalink
resolve inability to post GET params by using PUT instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinmarnold committed Aug 26, 2015
1 parent f2ac7e9 commit 1e65c38
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public class MainActivity extends BaseStingrayActivity {

@Override
protected void scheduleRequesters() {
// scheduleNearbyRequester();
scheduleNearbyRequester();
// scheduleFactoidsRequester();
// schedulePostStingrayReadingRequester();
schedulePostStingrayReadingRequester();
}


Expand Down Expand Up @@ -78,8 +77,10 @@ protected String getRequestParams() {
e.printStackTrace();
}

Log.d(TAG, "scheduleNearbyRequester: " + timeAndSpaceField);
return "time_and_space=" + nearbyFields.toString();

Log.d(TAG, "scheduleNearbyRequester: " + timeAndSpaceField.toString());
return timeAndSpaceField.toString();

}

@Override
Expand Down Expand Up @@ -154,7 +155,7 @@ public void onResponse(StingrayReading response) {
RecurringRequest recurringRequest = new RecurringRequest(FREQUENCY_VALUE, FREQUENCY_UNIT, postStingrayReadingRequester);
mStingrayAPIService.addRecurringRequest(recurringRequest);
}

public String getVersion() {
PackageManager pm = getPackageManager();
PackageInfo pInfo = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ protected void deliverResponse(T response) {
this.mSuccessListener.onResponse(response);
}

@Override
public String getBodyContentType()
{
return "application/json";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public NearbyRequester(StingrayAPIClientService stingrayAPIClientService) {

@Override
protected GsonRequest<StingrayReading[]> getRequest() {
return getRequest("nearby", Request.Method.GET, StingrayReading[].class);
return getRequest("nearby", Request.Method.PUT, StingrayReading[].class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import org.stingraymappingproject.api.clientandroid.GsonRequest;
import org.stingraymappingproject.api.clientandroid.StingrayAPIClientService;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
* Created by Marvin Arnold on 23/08/15.
*/
Expand All @@ -26,11 +23,7 @@ public String getRequestUrlForEndpoint(String endpointPath) {
}

public String getRequestUrlWParams(String endpointPath, String requestParams) {
try {
return getRequestUrlForEndpoint(endpointPath) + "?" + URLEncoder.encode(requestParams, "utf-8");
} catch (UnsupportedEncodingException e) {
return null;
}
return getRequestUrlForEndpoint(endpointPath) + "?" + requestParams;
}

public Requester(StingrayAPIClientService stingrayAPIClientService) {
Expand Down

0 comments on commit 1e65c38

Please sign in to comment.