Android Json parsing with retrofit - android

I'm using retrofit for the first time and I'm looking to parse some json data but I may have made a mistake initiating the network request on MainActivity. The App doesn't crush but it's not returning any values. it's a Gridlayout with an OnclickListener on each item and I'm only looking to return 2 values (name and Id ). The object currently has 3 items (name, id, and a List<>) this is the Full API end point "https://d17h27t6h515a5.cloudfront.net/topher/2017/May/59121517_baking/baking.json"
public class MainActivity extends AppCompatActivity implements
CakeAdapter.CakeClickedListener {
RecyclerView mRecyclerView;
TextView mCakeName;
ImageView mCakeImage;
TextView mCakeId;
private List<CakesItem> mCakeList = new ArrayList<>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = findViewById(R.id.cake_list_recycler_view);
mRecyclerView.setHasFixedSize(true);
GridLayoutManager mGridLayoutManager = new GridLayoutManager(MainActivity.this, 2);
final CakeAdapter mCakeAdapter = new CakeAdapter(this);
mRecyclerView.setLayoutManager(mGridLayoutManager);
mRecyclerView.setAdapter(mCakeAdapter);
mCakeAdapter.getCakeData(mCakeList);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
BakingJsonApi bakingJsonApi = retrofit.create(BakingJsonApi.class);
Call<List<CakesItem>> call = bakingJsonApi.getCakes(Constants.JSON_PATH);
call.enqueue(new Callback<List<CakesItem>>() {
#Override
public void onResponse(Call<List<CakesItem>> call, Response<List<CakesItem>> response) {
if (!response.isSuccessful()) {
Toast.makeText(MainActivity.this, "Code: " + response.code(), Toast.LENGTH_SHORT).show();
return;
}
List<CakesItem> cakeItem = response.body();
mCakeAdapter.getCakeData(cakeItem);
}
#Override
public void onFailure(Call<List<CakesItem>> call, Throwable t) {
Toast.makeText(MainActivity.this, "Unable to load data" + t.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
public interface BakingJsonApi {
#GET("/topher/2017/May/59121517_baking/{json}")
Call<List<CakesItem>> getCakes(#Path("json") String path);
}
class Constants {
static final String BAKING_API = "https://d17h27t6h515a5.cloudfront.net/topher/2017/May/59121517_baking/baking.json";
static final String BASE_URL = "https://d17h27t6h515a5.cloudfront.net/";
static final String JSON_PATH = "baking.json";
}

Maybe update Recycler-Adapter can work. I also modified your condition.
call.enqueue(new Callback<List<CakesItem>>() {
#Override
public void onResponse(Call<List<CakesItem>> call, Response<List<CakesItem>> response) {
if (response.isSuccessful()) {
mCakeList = new ArrayList();
mCakeList.addAll(response.body());
mCakeAdapter.notifyDataSetChanged();
}
}
#Override
public void onFailure(Call<List<CakesItem>> call, Throwable t) {
Toast.makeText(MainActivity.this, "Unable to load data" + t.getMessage(), Toast.LENGTH_SHORT).show();
}
});

Try change this condition :
if (!response.isSuccessful()) {
To something like t:
if(response.isSuccessful()){
Modelcake respuesta = response.body();
listcake.addAll(respuesta.getcake()); //in getcake() you get what are you want in your model
adapter.notifyDataSetChanged();
}else{
Log.e("API","onResponse"+response.errorBody());
}
With that should be work.

Related

How to POST retrofit return JSONArray with Root

i have a problem to take json with root/parent
Web Service
#POST("products")
Call<List<ProductResponse>> products(#Body ProductRequest productRequest);
My Model for Response
public class ProductResponse{
private String id_prodotto;
private String nome_prodotto;
}
My call response:
public void products(String s){
ProductRequest productRequest = new ProductRequest();
productRequest.setToken(s);
Call <List<ProductResponse>> pR =
ApiClient.getUserService().products(productRequest);
pR.enqueue(new Callback<List<ProductResponse>>() {
#Override
public void onResponse(Call<List<ProductResponse>> call, retrofit2.Response<List<ProductResponse>> response) {
if(response.isSuccessful()){
productList = response.body();
recyclerViewProdotti.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerViewProdotti.setHasFixedSize(true);
adapterProducts = new AdapterProducts(context.getApplicationContext(),productList,tkn);
recyclerViewProdotti.setAdapter(adapterProducts);
}else {
Toast.makeText(context,"Fail Products " + tkn, Toast.LENGTH_LONG).show();
}
}
#Override
public void onFailure(Call<List<ProductResponse>> call, Throwable t) {
Log.e("PR", t.getLocalizedMessage());
}
}
It's work when my response is:
{ "id_prodotto": "1", "nome_prodotto": "one"}
{ "id_prodotto": "2", "nome_prodotto": "two"}
But need take this response: { products: { "id_prodotto": "1", "nome_prodotto": "one"}
{ "id_prodotto": "2", "nome_prodotto": "two"}}
What i need to do?
You can use List<Object> since your response is like. But you need to remove List at the Webservice.
#POST("products")
Call<ProductListResponse> products(#Body ProductRequest productRequest);
Next, at you need to create new model class named ProductListResponse with using List.
public class ProductListResponse {
#SerializedName("products")
private List<ProductResponse> product;
}

Rapid API Error code 500 with Retrofit2 Android

I am using spoonacular API for a recipe app project. The problem occurs when trying to making multiple GET requests to the API. The first request is a simple search with a query parameter. The resulting JSON of the first request contains a Recipe ID and I use that ID to make the second GET request , where the problem occurs.
The API responds only when I make the request the first time but after that it responds with error code 500 [Internal Server Error].
I have tested the GET request on Postman but there it works fine every time.
I'm new to working with API's and any help would be immensely appreciated.
This is my Retrofit Service Class
public class ServiceGenerator {
public static final String API_BASE_URL = "https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/";
private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
private static Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create());
private static Retrofit retrofit = builder.build();
public static <S> S createService(Class<S> serviceClass, final String HostName, final String KeyVal)
{
if (!TextUtils.isEmpty(HostName) && !TextUtils.isEmpty(KeyVal))
{
HeadersInterceptor interceptor = new HeadersInterceptor(HostName,KeyVal);
if (!httpClient.interceptors().contains(interceptor))
{
httpClient.addInterceptor(interceptor);
builder.client(httpClient.build());
retrofit = builder.build();
}
}
return retrofit.create(serviceClass);
}
This is the Interceptor I am using to add Headers with the request.
public class HeadersInterceptor implements Interceptor {
private String HostName,KeyVal;
HeadersInterceptor(final String HostName,final String KeyVal) {
this.HostName = HostName;
this.KeyVal = KeyVal;
}
#NotNull
#Override
public Response intercept(#NotNull Chain chain) throws IOException {
Request original = chain.request();
Request.Builder builder = original.newBuilder()
.addHeader("X-RapidAPI-Host",HostName)
.addHeader("X-RapidAPI-Key",KeyVal);
Request request = builder.build();
return chain.proceed(request);
}
}
This is my Fragment which makes a search query and SUCCESSFULLY return results[Receipe ID's]
public class ListSelectedFragments extends Fragment {
private ProgressBar PreviewFragPrg;
private final String TAG = "ListSelectedFragment->";
private PreviewRecipeAdapter adapter;
private RecyclerView SelectedItemRV;
private ArrayList<RecipePreviewHolder> RecipePreviewsList = new ArrayList<>();
public ListSelectedFragments() {
// Required empty public constructor
}
#Override
public View onCreateView(#NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_list_selected_fragments, container, false);
SelectedItemRV = view.findViewById(R.id.SelectedItemRV);
TextView DisplayNameTV = view.findViewById(R.id.DisplayNameTV);
PreviewFragPrg = view.findViewById(R.id.PreviewFragPrg);
ImageView BackBtn = view.findViewById(R.id.BackBtn);
BackBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (getFragmentManager() != null) {
getFragmentManager().popBackStackImmediate();
}
}
});
if (getArguments() != null) {
final String QueryTag = getArguments().getString("QueryTag");
final String CuisineName = getArguments().getString("CuisineName");
if(CuisineName!=null){
DisplayNameTV.setText(CuisineName);
}
if(QueryTag!=null){
ProcessQuery(QueryTag);
}
}
return view;
}
private void ProcessQuery(final String QueryStr){
String hostname = getResources().getString(R.string.spoonacular_host_name);
String key = getResources().getString(R.string.spoonacular_apikey_val);
final ServiceGenerator.GetDataService mService =
ServiceGenerator.createService(ServiceGenerator.GetDataService.class, hostname,key);
Call<RecipeInfoModel> call = mService.getRecipes(QueryStr);
call.enqueue(new Callback<RecipeInfoModel>() {
#Override
public void onResponse(#NonNull Call<RecipeInfoModel> call,
#NonNull Response<RecipeInfoModel> response)
{
Log.d(TAG, "Request Response Received");
Log.d(TAG, response.toString());
if (response.body() != null) {
Results[] mRES = response.body().getResults();
SetUpRecipePreviews(mRES);
PreviewFragPrg.setVisibility(View.GONE);
}
}
#Override
public void onFailure(#NonNull Call<RecipeInfoModel> call, #NonNull Throwable t) {
Log.d(TAG, "Request Failed");
Log.d(TAG, call.toString());
Log.d(TAG, "Throwable ->" + t);
PreviewFragPrg.setVisibility(View.GONE);
Toast.makeText(getActivity(),"Could not get required recipes",Toast.LENGTH_SHORT).show();
}
});
Log.d(TAG, "User Inputed Request\n"+call.request().url().toString());
}
private void SetUpRecipePreviews(final Results[] mRES) {
RecipePreviewsList.clear();
adapter = new PreviewRecipeAdapter(getActivity(),RecipePreviewsList);
SelectedItemRV.setLayoutManager(new GridLayoutManager(getActivity(), 2));
SelectedItemRV.setAdapter(adapter);
for (Results mRE : mRES) {
String ImgUrls = mRE.getImage();
RecipePreviewHolder obj = new RecipePreviewHolder(Integer.valueOf(mRE.getId()),
mRE.getTitle(), ImgUrls);
Log.d("GlideLogs->","Rid->"+mRE.getId());
Log.d("GlideLogs->","Img URL->"+ ImgUrls);
Log.d("GlideLogs->","Name->"+mRE.getTitle());
RecipePreviewsList.add(obj);
}
if(RecipePreviewsList.size()>1){
adapter.notifyDataSetChanged();
}
}
This is the Activity I transition to from my Fragment after clicking on a Recipe Card... Sending the Recipe ID in the extras. This function is called immediately after receiving intent extras.
private void RetrieveRecipeInfo(final int recipeID) {
String hostname = getResources().getString(R.string.spoonacular_host_name);
String key = getResources().getString(R.string.spoonacular_apikey_val);
final ServiceGenerator.GetDataService mService =
ServiceGenerator.createService(ServiceGenerator.GetDataService.class, hostname,key);
Call<RecipeDetailedInfo> call = mService.getInformation(185071);
Log.d(TAG , "Your GET Request:\n"+call.request().url().toString());
call.enqueue(new Callback<RecipeDetailedInfo>() {
#Override
public void onResponse(#NonNull Call<RecipeDetailedInfo> call, #NonNull Response<RecipeDetailedInfo> response)
{
Log.d(TAG,"OnResponse() Called\n");
Log.d(TAG,"Response = "+ response);
if(response.body()!=null) {
String obj = response.body().getSourceUrl();
Log.d(TAG,"Getting Recipe Info\n");
Log.d(TAG, String.valueOf(obj));
}
}
#Override
public void onFailure(#NonNull Call<RecipeDetailedInfo> call, #NonNull Throwable t){
}
});
}
Using postman I get the results every time but in my application the API stops responding after the first request. Is there a problem with the way I'm including headers?
So I finally got things working. The problem was with the HeadersInterceptor.java. I was using the Interceptor to add the Headers with the call but I found out a much easier way and it works like a charm.
Simply add #Header with the call to add headers without interceptor in Retrofit.
public interface GetDataService {
#GET("recipes/complexSearch?")
Call<RecipeInfoModel> getRecipes(
#Header("X-RapidAPI-Host") String api,
#Header("X-RapidAPI-Key") String apiKey,
#Query("query") String query_str);
}

Model View Presenter with AA and Retrofit, not get data

i triying to do a simple MVP in Android using AndroidAnnotations and Retrofit2,
But I never get the information.
Code Presenter:
public class ListHomePresenter {
private List<Post> mPost;
Client client;
int error_code = 0;
String error_msg = "";
/**
* TODO: get all post
* */
public List<Post> getPost() throws SampleExceptions{
RestService restService;
client = new Client();
restService = client.getApi();
Call<List<Post>> task = restService.downloadPost();
task.enqueue(new Callback<List<Post>>() {
#Override
public void onResponse(Call<List<Post>> call, Response<List<Post>> response) {
mPost = response.body();
}
#Override
public void onFailure(Call<List<Post>> call, Throwable t) {
mPost = null;
error_code = 1; // error
error_msg = t.getMessage(); // message
}
});
if(error_code == 1 )
throw new SampleExceptions(error_code, "Error");
return mPost;
}
}
Code Activity
#EActivity(R.layout.activity_home)
public class HomeActivity extends AppCompatActivity {
#ViewById(R.id.rvPosts)
RecyclerView mRvPost;
PostAdapter mPostAdapter;
ListHomePresenter mListHomePresenter;
private StaggeredGridLayoutManager gaggeredGridLayoutManager;
#AfterViews
void setupHome(){
downloadPost();
}
#UiThread(propagation = Propagation.REUSE)
void downloadPost(){
try{
mListHomePresenter = new ListHomePresenter();
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
mRvPost.setLayoutManager(gaggeredGridLayoutManager);
mPostAdapter = new PostAdapter(HomeActivity.this, mListHomePresenter.getPost());
mRvPost.setAdapter( mPostAdapter );
}catch (SampleExceptions e){
}
}
}
but, ever i getting the null data.
Help Me!
Here an example:
Presenter:
public class ListHomePresenter {
private List<Post> mPost;
Client client;
int error_code = 0;
String error_msg = "";
HomeView view;
public ListHomePresenter(HomeView view) {
this.view = view;
}
/**
* TODO: get all post
* */
public void loadPost() throws SampleExceptions{
RestService restService;
client = new Client();
restService = client.getApi();
Call<List<Post>> task = restService.downloadPost();
task.enqueue(new Callback<List<Post>>() {
#Override
public void onResponse(Call<List<Post>> call, Response<List<Post>> response) {
view.retrieveData(response.body());
}
#Override
public void onFailure(Call<List<Post>> call, Throwable t) {
mPost = null;
error_code = 1; // error
error_msg = t.getMessage(); // message
}
});
if(error_code == 1 )
throw new SampleExceptions(error_code, "Error");
}
}
Activity:
#ViewById(R.id.rvPosts)
RecyclerView mRvPost;
PostAdapter mPostAdapter;
ListHomePresenter mListHomePresenter;
private StaggeredGridLayoutManager gaggeredGridLayoutManager;
#AfterViews
void setupHome() {
downloadPost();
}
#UiThread(propagation = Propagation.REUSE)
void downloadPost() {
try {
mListHomePresenter = new ListHomePresenter(this);
mListHomePresenter.loadPost()
} catch (SampleExceptions e) {
}
}
// Method implemented from view interface
#Override
void retrieveData(List<Post> postList) {
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
mRvPost.setLayoutManager(gaggeredGridLayoutManager);
mPostAdapter = new PostAdapter(HomeActivity.this, postList);
mRvPost.setAdapter(mPostAdapter);
}
Only you needs implement an interface view to interacts between two classes
You have a race condition on your getPost method, when return mPost, the callback has not yet returned the response.
I recommend that the getPost method does not return anything, and once you pass onResponse, you call a view method that fills the adapter.
This ensures that you will always have data.

How to use a Retrofit response in another places

I am using Retrofit in my application and receiving data from my server.
I receive data from my server in responseBody in Retrofit, but when I want to use these received data, my array is null?!!
Here is my class:
public class ActivityApplicationsList extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_applications_list);
Log.i(TAG , "size of response array: " + populateDataFromServer().size())
//this size is 0 but have to be 4 !
}
private ArrayList<StructApplication> populateDataFromServer() {
final ArrayList<StructApplication> mine = new ArrayList<>();
final APIService service = ServiceGenerator.createService(APIService.class, "2015-03-01 14:26:00", "123456", "123456");
Call<ArrayList<AppModel>> call = service.getApp();
call.enqueue(new Callback<ArrayList<AppModel>>() {
#Override
public void onResponse(Call<ArrayList<AppModel>> call, Response<ArrayList<AppModel>> response) {
ArrayList<AppModel> newAppModel = response.body();
for(int i=0 ; i < newAppModel.size();i++){
StructApplication structApplication = new StructApplication();
structApplication.setName(String.valueOf(newAppModel.get(i).getAppId()));
structApplication.setId(newAppModel.get(i).getAppId());
structApplication.setAppVersionReleaseDate(newAppModel.get(i).getAppVersionReDate());
structApplication.setAppDeleted(newAppModel.get(i).getAppDeleted());
mine.add(structApplication);
}
}
#Override
public void onFailure(Call<ArrayList<AppModel>> call, Throwable t) {
}
});
return mine;
}
}
And I debugged to make sure that all data received in onResponse:
As you can see, I received all data correctly, but when I use this response in onCreate of this class it's null!
I really appreciate your answer about this weird problem.
This is because you are printing your list size before the response comes. As request is being sent asynchronously, and your are trying to get size before onResponse() callback method.
try to add this line
Log.i(TAG , "size of response array: " + populateDataFromServer().size())
in onResponse() method after mine.add(structApplication); you will see the right size.
Its return first and execute later, try this way...
private ArrayList<StructApplication> populateDataFromServer() {
final ArrayList<StructApplication> mine = new ArrayList<>();
final APIService service = ServiceGenerator.createService(APIService.class, "2015-03-01 14:26:00", "123456", "123456");
Call<ArrayList<AppModel>> call = service.getApp();
Response<ArrayList<AppModel>> response = responseCall.execute();
ArrayList<AppModel> newAppModel = response.body();
for(int i=0 ; i < newAppModel.size();i++){
StructApplication structApplication = new StructApplication();
structApplication.setName(String.valueOf(newAppModel.get(i).getAppId()));
structApplication.setId(newAppModel.get(i).getAppId());
structApplication.setAppVersionReleaseDate(newAppModel.get(i).getAppVersionReDate());
structApplication.setAppDeleted(newAppModel.get(i).getAppDeleted());
mine.add(structApplication);
}
return mine;
}
It is happening due to api calling because api taking few seconds to get response and meanwhile you returned your mine array. So please return response once you got value from server.
Do like this
Make a global instance for this class like
public class ActivityApplicationsList extends Activity {
ArrayList<StructApplication> mine = new ArrayList();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_applications_list);
populateDataFromServer();
Log.i(TAG , "size of response array: " + mine.size());
}
private void populateDataFromServer() {
final APIService service = ServiceGenerator.createService(APIService.class, "2015-03-01 14:26:00", "123456", "123456");
Call<ArrayList<AppModel>> call = service.getApp();
call.enqueue(new Callback<ArrayList<AppModel>>() {
#Override
public void onResponse(Call<ArrayList<AppModel>> call, Response<ArrayList<AppModel>> response) {
ArrayList<AppModel> newAppModel = response.body();
for(int i=0 ; i < newAppModel.size();i++){
StructApplication structApplication = new StructApplication();
structApplication.setName(String.valueOf(newAppModel.get(i).getAppId()));
structApplication.setId(newAppModel.get(i).getAppId());
structApplication.setAppVersionReleaseDate(newAppModel.get(i).getAppVersionReDate());
structApplication.setAppDeleted(newAppModel.get(i).getAppDeleted());
mine.add(structApplication);
}
}
#Override
public void onFailure(Call<ArrayList<AppModel>> call, Throwable t) {
}
});
}
}
You need to get the response after the request. See code comments
public class ActivityApplicationsList extends Activity
implements Callback<ArrayList<AppModel>> { // Implement callback here
// These are final, so make them fields
final ArrayList<StructApplication> mine = new ArrayList<>();
final APIService service = ServiceGenerator.createService(APIService.class, "2015-03-01 14:26:00", "123456", "123456");
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_applications_list);
populateDataFromServer();
}
// Callback implementation
#Override
public void onResponse(Call<ArrayList<AppModel>> call, Response<ArrayList<AppModel>> response) {
final ArrayList<AppModel> responseBody = response.body();
for(AppModel model : responseBody){
StructApplication structApplication = new StructApplication();
structApplication.setName(String.valueOf(model.getAppId()));
structApplication.setId(model.getAppId());
structApplication.setAppVersionReleaseDate(model.getAppVersionReDate());
structApplication.setAppDeleted(model.getAppDeleted());
mine.add(structApplication);
}
// adapter.notifyDataSetChanged(); // Need this if using ListView
Log.d("SIZE", ""+mine.size()); // Correct size
}
#Override
public void onFailure(Call<ArrayList<AppModel>> call, Throwable t) {
// error
}
private void populateDataFromServer() { // this is void; it can't return
service.getApp().enqueue(ActivityApplicationsList.this);
}
Suggestion, make this constructor
public class StructApplication {
public StructApplication(AppModel model) {
setName(String.valueOf(model.getAppId());
setId(model.getAppId());
setAppDeleted(model.getAppDeleted());
setAppVersionReleaseDate(model.getAppVersionReDate());
}
}
Then, that loop can simply be
mine.add(new StructApplication(model));

How to handle onResponse method by using Retrofit library?

I am using retrofit library.I have created a class in which i am getting the value of particular id from other class, and i want to fetch particular list of that id but in the onResponse() method am getting an error. i checked in the postman in json format the list is fetching......but not here!
public class Main2Activity extends AppCompatActivity implements Callback<MailChimpEmailResponse> {
public String idReceived;
List<MailChimpEmailResponseSecond> emailList = new ArrayList<>();
private RecyclerView recyclerViewSecond;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Call<MailChimpEmailResponse> call = MailChimpAPIClient.getClient().fetchMembers(idReceived,"efb918ee88a3a8a77-us15" );
call.enqueue(this);
}
#Override
public void onResponse(Call<MailChimpEmailResponse> call, Response<MailChimpEmailResponse> response) {
Log.d("ashu", "null response");
Intent intent = getIntent();
idReceived = intent.getStringExtra("id_value");
Log.d("ashu", "id received is: " + idReceived);
MailChimpEmailResponse listResponse = response.body();
for (MailChimpEmailResponseSecond list : listResponse.emailLists) {
Log.d("ashu", list.getEmailListName());
this.emailList = listResponse.emailLists;
}
recyclerViewSecond = (RecyclerView) findViewById(R.id.my_recycler_view_second);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
recyclerViewSecond.setLayoutManager(linearLayoutManager);
EmailAdapter adapter = new EmailAdapter(this.emailList);
recyclerViewSecond.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
#Override
public void onFailure(Call<MailChimpEmailResponse> call, Throwable t) {
}
}
my api class:
public interface MailChimpApi {
#GET("lists")
public Call<MailChimpListResponse> fetchLists(#Query("apikey") String apikey, #Query("offset") int offset, #Query("count") int count);
#GET("lists/{list_id}/members")
public Call<MailChimpEmailResponse> fetchMembers(#Path("list_id") String listId,#Query("apikey") String apikey);
}
my json:
{
"members": [
{
"id": "04d80020e78edd86a79eda",
"email_address": "ashuingh.02046547#gmail.com",
"unique_email_id": "784c772918",
"email_type": "html",
"status": "subscribed",
"merge_fields": {
"FNAME": "Ashsdjssh",
"LNAME": "kudjskjar"
},
I believe the following line should be in onCreate method instead of onResponse,
idReceived = intent.getStringExtra("id_value");

Categories

Resources