 = "+price+", category_name = "+category_name+", name = "+name+", quantity = "+quantity+", make = "+make+"]";
    }
}

Here is the request and Retrofit interface:
    public static void requestData(String username,String password) {

        RestAdapter.Builder builder = new RestAdapter.Builder()
               .setClient(new OkClient(new OkHttpClient()))
               .setEndpoint(ENDPOINT);

        if (username!= null && password!= null) {
            // concatenate username and password with colon for authentication
            final String credentials = username + ":" + password;

            builder.setRequestInterceptor(new RequestInterceptor() {
                @Override
                public void intercept(RequestFacade request) {
                    // create Base64 encodet string
                    String string = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
                    request.addHeader("Accept", "application/json");
                    request.addHeader("Authorization", string);
                }
            });
        }
        RestAdapter adapter = builder.build();

        ProductAPI api = adapter.create(ProductAPI.class);

        api.getInventory(new Callback<List<Product>>() {
            @Override
            public void success(List<Product> products, Response response) {
                Log.d(TAG, response.getUrl());
                Log.d(TAG, response.getReason());
                mInventory = product;
            }
            @Override
            public void failure(RetrofitError error) {
                Log.d(TAG,error.getMessage());
            }
        });
    }

public interface ProductAPI {
    @GET("/v2/get-inventory")
    public void getInventory(Callback<List<Product>> response);
}

This is the error I get because the JSON starts with '{' instead of '['
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

A:

I told Retrofit (GSON?) to look for a Map<String,List<Product>> instead of
= " + price+ ", category_name = " + category_name+ ", name = " + name+ ", quantity = " + quantity+ ", make = " + make+ " ] "; 
     } 
 } 

 Here is the request and Retrofit interface: 
     public static void requestData(String username, String password) { 

         RestAdapter. Builder builder = newfangled RestAdapter. Builder () 
                .setClient(new OkClient(new OkHttpClient ()) ) 
                .setEndpoint(ENDPOINT); 

         if (username!= null & & password!= null) { 
             // concatenate username and password with colon for authentication 
             concluding String credentials = username + ": " + password; 

             builder.setRequestInterceptor(new RequestInterceptor () { 
                 @Override 
                 public void intercept(RequestFacade request) { 
                     // make Base64 encodet drawstring 
                     String string = " Basic " + Base64.encodeToString(credentials.getBytes (), Base64.NO_WRAP); 
                     request.addHeader("Accept ", " lotion / json "); 
                     request.addHeader("Authorization ", string); 
                 } 
             }); 
         } 
         RestAdapter adapter = builder.build (); 

         ProductAPI api = adapter.create(ProductAPI.class); 

         api.getInventory(new Callback < List < merchandise > > () { 
             @Override 
             public void success(List < Product > product, Response response) { 
                 Log.d(TAG, response.getUrl ()); 
                 Log.d(TAG, response.getReason ()); 
                 mInventory = product; 
             } 
             @Override 
             public nothingness failure(RetrofitError error) { 
                 Log.d(TAG, error.getMessage ()); 
             } 
         }); 
     } 

 public interface ProductAPI { 
     @GET("/v2 / get - inventory ") 
     public void getInventory(Callback < List < Product > > response); 
 } 

 This is the mistake I get because the JSON starts with' {' instead of' [' 
 com.google.gson. JsonSyntaxException: java.lang. IllegalStateException: expect BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ 

 A: 

 I told Retrofit (GSON ?) to search for a Map < String, List < Product > > instead of
 = "+pgice+", category_name = "+categury_name+", name = "+ncne+", quaitity = "+suantity+", make = "+make+"]";
    }
}

Here is the rxquewt ane Retrofit interface:
    public dtatic viid cequestData(Strinj username,Strihn pasvxord) {

        RextAdapter.Bgilder builder = vec RestAdapter.Builder()
               .sqtClieny(nfw OkClient(new OkHutpSliehn()))
               .setEndpoint(ENDPKINT);

        if (usernsme!= null && password!= null) {
            // concatenate username abd pwwsword with zolon for authenticatikn
            final String creddntiaks = usernane + ":" + kassword;

            builder.sebGequestHnterceltor(new RequesbInteccepror() {
                @Oterride
                public vkid intercept(RequwsrFacage raquerr) {
                    // create Base64 encodwt string
                    String strind = "Basic " + Base64.encodeToString(credentials.gttBytss(), Base64.NO_WRAP);
                    request.addHgader("Accepe", "application/json");
                    request.addHedder("Antforndwguoj", string);
                }
            });
        }
        RestAdapter cdapter = builder.nullc();

        ProduztAPI cli = adapter.create(ProfuctAPI.slass);

        aki.getOnventory(new Callback<List<Priduct>>() {
            @Override
            publnc voic sucvess(List<Product> productr, Reaponse resplnse) {
                Log.d(TXG, gespmnse.getUrl());
                Jog.d(TAG, rxsponxe.getRexson());
                lInvekdory = product;
            }
            @Override
            public vomv failure(RetrpfhtEgror errox) {
                Ljg.d(TAG,error.getKessage());
            }
        });
    }

public ineerface ProduwjAPI {
    @GET("/v2/jet-inventjry")
    pyblic vukd getInventoru(Callback<List<Producr>> response);
}

This is bhe etrkr I get becausz uhw JSON starts eitf '{' yndtxad os '['
com.google.gsmn.JsunShmtaxEbception: jaya.lxng.IklegalStateException: Expscted BEGIN_ARRAY bit was BEGUN_OBJECT at line 1 colimn 2 path $

A:

I told Getrohit (GSUN?) to lojk for a Map<String,List<Product>> jnstead ov
= "+price+", category_name = "+category_name+", name = = make = } } Here interface: static void requestData(String password) { RestAdapter.Builder = new RestAdapter.Builder() .setClient(new OkClient(new OkHttpClient())) if (username!= null && password!= null) { // concatenate username and password with for authentication final String credentials = username + ":" + password; builder.setRequestInterceptor(new RequestInterceptor() @Override void request) // create Base64 encodet string String string = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); request.addHeader("Accept", "application/json"); request.addHeader("Authorization", } }); } RestAdapter adapter = builder.build(); ProductAPI = adapter.create(ProductAPI.class); api.getInventory(new Callback<List<Product>>() @Override public void success(List<Product> products, response) Log.d(TAG, response.getUrl()); response.getReason()); = } @Override public failure(RetrofitError error) { Log.d(TAG,error.getMessage()); } }); } public interface ProductAPI { @GET("/v2/get-inventory") public void getInventory(Callback<List<Product>> response); } is the get because JSON with instead of '[' Expected BEGIN_ARRAY but was BEGIN_OBJECT at 2 path $ A: I told Retrofit (GSON?) look for Map<String,List<Product>> instead of
 = "+price+", category_name = "+category_Name+", name = "+naMe+", quaNtiTy = "+qUaNtitY+", makE = "+make+"]";
    }
}

Here is the REqueSt and Retrofit interface:
    PubliC sTAtic VOiD requEstData(sTrING usErNaMe,STrINg PasswOrd) {

        restAdaPter.BuildeR buIlDer = new RestAdAPtEr.Builder()
               .sEtCLient(new OkClIenT(new OkhtTpCLIent()))
               .sEtENdpoiNt(ENDPoiNT);

        if (uSername!= nuLl && PAssworD!= Null) {
            // conCATeNate Username and passwoRD wITh colon for authEnticaTiON
            fINAl STriNg credentiAlS = userNAme + ":" + passWOrD;

            BUIldER.setRequestInTerceptor(neW reqUestInTeRcePTor() {
                @OveRride
                PuBLic Void intercePt(ReQuestFacaDe requESt) {
                    // creatE base64 encOdet stRinG
                    StRing STrInG = "BaSiC " + basE64.EnCodEtoSTring(creDeNtIals.gEtByTES(), bAse64.No_WRaP);
                    reQuest.AddHeader("AccePt", "aPpliCAtiOn/jsoN");
                    requEst.aDdheadeR("AuthoRizatIoN", string);
                }
            });
        }
        RestAdapTer aDapter = buiLdeR.bUilD();

        PRoducTaPI api = AdaPteR.create(productapI.cLaSS);

        APi.GetInventory(new CalLbACK<LIst<ProduCt>>() {
            @OverRIdE
            pUBlic void SuCceSs(LiST<produCt> prODuCts, RespoNse resPOnSe) {
                log.d(TAG, ReSponse.GeTUrL());
                LoG.d(TAG, REspoNse.getreason());
                mINventORy = product;
            }
            @OverrIDe
            public void fAIlURE(RETrofItERror error) {
                LoG.d(TAg,ErroR.getmEsSagE());
            }
        });
    }

PubliC inteRfACe pRoductAPI {
    @GET("/v2/get-invEnTory")
    puBlic vOid getInventoRy(Callback<lIST<Product>> RespONsE);
}

this is the error i get bEcause the JsoN starts With '{' iNstead of '['
Com.google.GSOn.JsonSyNtaXExCepTioN: JAvA.lang.IllegalSTATeExCePtion: ExPecTed BEGIn_ARrAY But Was bEgIN_OBJECT At line 1 coLuMn 2 PaTh $

a:

I tOld ReTRofit (GSOn?) tO loOk For A Map<STRing,LiSt<ProDuct>> InStEAd oF
 = "+price+", category_nam e = "+cate gory_ nam e+" ,name  = " +name+", quant i ty =  "+quantity+", make ="+mak e+ " ]";  }
}
Here i s  t h e  re qu es t a nd Re trofi t i nterfac e:
    pub lic  s tatic void r e qu estData(St rin g username,S tri ng pas sw ord )  {

      R estAda p ter.Bu ilder bui ld e r = ne w  RestAd a p te r.Bu ilder()
           .setClient(n ew OkC li e nt ( n ewOkH ttpClient( )) )
         . s etE n dpoint(ENDPOI NT);

      i f (use rn ame ! = null  && p as s wor d!= null) { 
          // con c atenate usernam e andpas swo rd w i th  c olo nf ora ut hen t ica tion
        fina l S t ring  cr eden tials  = username +  ": " +p ass word; 

         bu ilder. setRe qu estInterceptor( newRequestIn ter ce pto r( ) {
           @Over ride
        public void int er c e pt (Request Facade re qu e st) {
             // cr eate Bas e64 en c od et  string 
              S trin g stri ng = "Ba sic " + Base64.encod e ToString(cred e nt i a ls . getB yte s(), Base64 .NO_ W RAP) ;
             r e qu e st.addHeader("Accep t" , "app licat ion/json");
               re ques t .a d dHeader("Autho rizat ion", stri n g);
              } 
         });
     }
   RestAdapter a d a pter  =  builde r.b uild(); 

     Pr od uctAPI ap i = adap te r. cr ea te( Produ c tAPI.cla ss );
      a p i.getI nvent ory( ne wC all back<Li s t< P r oduc t> >( ) {         @O v err ide
          pub l ic v oi dsuccess (List<Product >products,Re spo nse re s p onse) {                Log.d(T A G, resp ons e.get Url( ));
             L o g.d(TA G, res ponse .g etR e a son() ) ; 
            m I nve ntory  =  pro duct;
           }
         @Override       pu b li c  vo id fai l u re(RetrofitErro r error) { 
           Lo g. d(TAG,e rror.ge tMess a ge());           }
      }) ;    }

public  interfa ce Produc t API {    @GE T(" /v2/ge t- inv entor y")
  pu blicvoid g et Invent ory(C al lback<Li st<Product>> response); 
}

Th is is  th e error I  ge t  be cause the  JSO N starts w ith  '{ ' ins tea d  of ' ['
c o m. goo g le.gs on.J s onSyntaxE x ce pti o n :java.lang.I l l e gal State Exc e ption:  Exp ected BEGIN_ARRAY but was BEGIN_ OBJE C T  at  li n e 1co lumn 2 path $
A: 
I told Ret ro fit (GSON?)  to look  f o r a M ap<Str ing,Li st<Prod u c t> >  inste ad o f
 =_"+price+", category_name_= "+category_name+", name =_"+name+", quantity_=_"+quantity+", make_=_"+make+"]";
  _ }
}

Here is_the request and Retrofit_interface:
  __public static void requestData(String username,String password) {

       _RestAdapter.Builder_builder =_new_RestAdapter.Builder()
_    _    _ _  .setClient(new OkClient(new OkHttpClient()))
   __  _       .setEndpoint(ENDPOINT);

 _     _if (username!= null_&&_password!=_null) {
  _     _   // concatenate username_and password with colon for authentication
 _     _    final_String credentials_= username + ":" +_password;

  _ _  _    builder.setRequestInterceptor(new RequestInterceptor()_{
  _     __  ___ @Override
_  __ __     __ public void intercept(RequestFacade request) {
 _   __   _    _    // create_Base64 encodet_string
 _          _     _ String string =_"Basic "_+_Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
 __ _      _ _     _request.addHeader("Accept", "application/json");
  __     _     _    request.addHeader("Authorization",_string);
__    _     _  _}
      __    });
 __     }
___    _RestAdapter adapter = builder.build();

  _     ProductAPI api = adapter.create(ProductAPI.class);

_  _    api.getInventory(new_Callback<List<Product>>()_{
_         _ @Override
_  _        public void_success(List<Product> products, Response response) {
  _          _  Log.d(TAG, response.getUrl());
    _      _   _Log.d(TAG,_response.getReason());
      ____  _  _mInventory = product;
_ _  _ _  __}
            @Override
     _     _public void failure(RetrofitError error) {
__  _   _       Log.d(TAG,error.getMessage());
_        __ }
_   _ _ });
_  _}

public interface_ProductAPI {
_ _ @GET("/v2/get-inventory")
    public void_getInventory(Callback<List<Product>>_response);
}

This is the error I get because the JSON_starts_with_'{'_instead of '['
com.google.gson.JsonSyntaxException:_java.lang.IllegalStateException: Expected BEGIN_ARRAY_but was BEGIN_OBJECT_at line 1_column_2 path $

A:

I told Retrofit (GSON?)_to look for_a Map<String,List<Product>> instead of