Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.danielhartman.retrofitexample;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import java.util.List;
- import model.Results;
- import retrofit.Call;
- import retrofit.Retrofit;
- import retrofit.http.GET;
- import retrofit.http.Headers;
- public class MainActivity extends AppCompatActivity {
- public interface myInterface{
- @Headers({
- "X-Parse-Application-Id:NNGfkEU1J9i5nWtJGY5EPhVdWAJrr86noDrDheyr",
- "X-Parse-REST-API-Key:LiVXTVok9mmWyYcuhd8eHpYpq9VLJZmyk4nJJGGW"
- })
- @GET("1/classes/Workout")
- Call<List<Results>> response();
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Retrofit retrofit = new Retrofit.Builder()
- .baseUrl("https://api.parse.com")
- .build();
- myInterface service = retrofit.create(myInterface.class);
- Call<List<Results>> repos = service.response();
- }
- }
- package model;
- /**
- * Created by dphart9 on 9/2/2015.
- */
- public class Results {
- private String createdAt;
- private String objectId;
- private String updatedAt;
- private String workoutName;
- public String getCreatedAt() {
- return createdAt;
- }
- public void setCreatedAt(String createdAt) {
- this.createdAt = createdAt;
- }
- public String getObjectId() {
- return objectId;
- }
- public void setObjectId(String objectId) {
- this.objectId = objectId;
- }
- public String getUpdatedAt() {
- return updatedAt;
- }
- public void setUpdatedAt(String updatedAt) {
- this.updatedAt = updatedAt;
- }
- public String getWorkoutName() {
- return workoutName;
- }
- public void setWorkoutName(String workoutName) {
- this.workoutName = workoutName;
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- What is returned when I do the API Call in python
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- "results": [
- {
- "createdAt": "2015-09-02T14:51:46.449Z",
- "objectId": "Hm82yMZf1t",
- "updatedAt": "2015-09-02T14:51:46.449Z",
- "workoutName": "workout One"
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement