I have a Problem when using retrofit. I want to submit some nested parameters to my Server-Application. So my tool_params should be a Map like
tool_paramters<String,Hashmap<String,String>>
Here is the Interface of my create Action.
@POST("/api/tools") public void createTool(@QueryMap HashMap<String,String> login_paramters,@QueryMap HashMap<String, HashMap<String,String>> tool_parameters, Callback<ResponseForDeleteAction> callback);
I want to create Paramters which looks like this on my server :
Parameters: {"utf8"=>"✓", "authenticity_token"=>"iQbDzKazwfQERslHmlSY4yoCyjXY0qTAIAsc3tVJOyU=", "tool"=>{"serialnumber"=>"fdsaf", "name"=>"fasdf", "wallthickness"=>"fadsf", "toolmaterial_id"=>"1"}, "commit"=>"Werkzeug erstellen"}
But if using my Interface it will look like this :
Parameters: {"user_token"=>"qZfWPcJC-u7zqqekta_c", "tool"=>"{serialnumber=dggd, wallthickness=ghgf, name=fghe}"}
So it creates a String of my Tool-paramters values and i dont know why. So what i am doing wrong here ?
Here is how i build my paramters :
// Create an instance of our AsynchronousApi interface.
RomoCloudInterface asyncApi = restAdapter.create(RomoCloudInterface.class);
HashMap<String,String>login_parameters = new HashMap<String,String>();
login_parameters.put("user_token", accessToken);
HashMap<String,HashMap<String,String>>tool_parameters = new HashMap<String, HashMap<String, String>>();
HashMap<String,String>tool_fields = new HashMap<String,String>();
EditText serialNumberEditText = (EditText) findViewById(R.id.editText_serialnumber_tool);
EditText wallthicknessEditText = (EditText) findViewById(R.id.editText_wallthickness_tool);
EditText nameEditText = (EditText) findViewById(R.id.editText_name_tool);
tool_fields.put("serialnumber", serialNumberEditText.getText().toString());
tool_fields.put("name", wallthicknessEditText.getText().toString());
tool_fields.put("wallthickness", nameEditText.getText().toString());
tool_parameters.put("tool", tool_fields);
asyncApi.createTool(login_parameters,tool_parameters,new Callback<ResponseForDeleteAction>() { ..... //foo
0 comments:
Post a Comment