The situation is the following, you need to send POST to the server using http basic auth. The data that you need to send must be json, type

{ "value1": [ { "value2": "param1", "value3": "param2" } ] } 

Is it possible to simply make this json, toString (), and transfer to the server, or is there a mechanism for Retrofit for this, and tell me about basic auth, maybe what I am doing wrong.

This is in the Api class.

  public void getUserInfo(@Field("user") String userName, Callback<Response> cb); 

This is for sending json and basic auth.

  final String basic = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); RestAdapter.Builder builder = new RestAdapter.Builder() .setEndpoint("http://api") .setClient(new OkClient(new OkHttpClient())) .setLogLevel(RestAdapter.LogLevel.FULL); builder.setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade request) { request.addHeader("Authorization", basic); // request.addHeader("Accept", "application/vnd.api+json"); } }); RestAdapter restAdapter = builder.build(); TestId service = restAdapter.create(TestId.class); service.getUserInfo(resultJsonStart.toString(), new Callback<Response>() { public void success(Response arg0, retrofit.client.Response arg1) { stringFromResponse(arg1); System.out.println(arg1.toString()); } public void failure(RetrofitError arg0) { System.out.println(arg0.toString()); } }); 
  • one
    может я что не так делаю to know what else you are doing ... - Vladyslav Matviienko
  • Oh, sorry, I wanted to add, but the campaign was distracted. - DemD10

0