Skip to content

Instantly share code, notes, and snippets.

@tub216
Forked from rciovati/MyRequest.java
Created June 11, 2014 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tub216/10dd8f7d3cbc4be9d00c to your computer and use it in GitHub Desktop.
Save tub216/10dd8f7d3cbc4be9d00c to your computer and use it in GitHub Desktop.
import com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
public class MyRequest extends SpringAndroidSpiceRequest<MyResponse> {
public MyRequest(){
super(MyResponse.class);
}
@Override
public MyResponse loadDataFromNetwork() throws Exception {
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
parameters.set("foo", "bar");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(parameters, headers);
return getRestTemplate().postForObject("http://www.yoursite.com", request, MyResponse.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment