Main Activity
String user_id = Utility.getPrefs("user_id", Manager_photo.this);
String user_role_id = Utility.getPrefs("user_role_id", Manager_photo.this);
RequestBody userId = RequestBody.create(MediaType.parse("text/plain"), user_id);
RequestBody passRoleId = RequestBody.create(MediaType.parse("text/plain"), user_role_id);
RequestBody manager_name = RequestBody.create(MediaType.parse("text/plain"), name);
RequestBody phone_number = RequestBody.create(MediaType.parse("text/plain"), mobile);
RequestBody address = RequestBody.create(MediaType.parse("text/plain"), m_address);
RequestBody country = RequestBody.create(MediaType.parse("text/plain"), m_country);
RequestBody state = RequestBody.create(MediaType.parse("text/plain"), m_state);
RequestBody city = RequestBody.create(MediaType.parse("text/plain"), m_city);
RequestBody user_name = RequestBody.create(MediaType.parse("text/plain"), user);
RequestBody password = RequestBody.create(MediaType.parse("text/plain"), pass);
RequestBody managerPhoto = RequestBody.create(MediaType.parse("png"), cust_file);
HashMap body = new HashMap<>();
body.put("manager_name", manager_name);
body.put("phone_number", phone_number);
body.put("address", address);
body.put("country", country);
body.put("state", state);
body.put("city", city);
body.put("user_name", user_name);
body.put("password", password);
body.put("user_id", userId);
body.put("user_role_id", passRoleId);
body.put("userfile", managerPhoto);
Log.i("requserstbody", body.toString());
Retrofit retrofit = Utility.builder.build();
MyApiEndpointInterface endpointInterface = retrofit.create(MyApiEndpointInterface.class);
Call<BasicResponse> call = endpointInterface.addManger(body);
call.enqueue(new Callback<BasicResponse>() {
@Override
public void onResponse(Call<BasicResponse> call, Response<BasicResponse> response) {
Interface
[@Multipart
@POST("api/rest/manager")
Call<BasicResponse> addManger(@PartMap Map<String, RequestBody> params);][1]
Part Of request body okhttp logged
--029eed44-e080-4028-a980-fdb70985e6ef
01-30 10:43:49.184 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Disposition: form-data; name="city"
01-30 10:43:49.184 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Transfer-Encoding: binary
01-30 10:43:49.184 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Type: text/plain; charset=utf-8
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Length: 3
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: fhv
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: --029eed44-e080-4028-a980-fdb70985e6ef
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Disposition: form-data; name="state"
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Transfer-Encoding: binary
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Type: text/plain; charset=utf-8
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Length: 3
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: yih
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: --029eed44-e080-4028-a980-fdb70985e6ef
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Disposition: form-data; name="userfile"
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Transfer-Encoding: binary
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: Content-Length: 28681
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: �PNG
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp:
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: ������IHDR������l��������������i^�������sBIT��O����� ��IDATx�4����Ȏ$�� �̼�=m�00�y�Wk�[y$�>eq��dT�������������͙�����XS����p�U#\�2����>� � �?~�����,��s��Md�_�<]?����r?M�V:n�Xx��������,6`kM��-�焞�<��yz����oh��y}�'8>�>��u�k���s��bɓώ�x�������(�ke����?��M�����Z���S�UX�ϮS{/����9��}�霾k����XZ���^�%��+��%��g��YJf_�Z�U??YH"a�Z��";�\�韟R?����zqپ�k=�R=�q�}��Ժm����Sw�`Z�@ݳ�ݓ���K�����_��������.��ϯ��J>������|�Y���߇���Y��_��>�������'���8�qݕ����s��t]?�%�g���6Ø�uߖXĺt��
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: �������k{pגG¤��[&TW]������6RNpm�b_��!mp�Z\1y!����D:���z��^\�3H�go�������_�MƧ_WMpm�Ư���Y몟�y�g�Ɵ/?�~�=�:���
01-30 10:43:49.185 19296-19691/com.programer.nivin.tourism D/OkHttp: +�z]�������S����z��2�V}2��'�w����3�M��{}���c0w��~�(�E�|��t_��TX������q0�=�%I�b���:{a���d��E>鶗��?��������������_�d�_��
01-30 10:43:49.186 19296-19691/com.programer.nivin.tourism D/OkHttp: �^�P]y����ԃ���{�=�'�����8?7��q���?3(/�l��H�g��j��_��\�d����Z3������{c��ֽ�U���?Ƥ53w�.�u{C�!P��<�JK���$��4Q��������q��
01-30 10:43:49.186 19296-19691/com.programer.nivin.tourism D/OkHttp: �8��/�3�t�e��y������^-��dn��]�]��=��|2/x����S��F�}�s?w��o�|�z]7�'u�
01-30 10:43:49.186 19296-19691/com.programer.nivin.tourism D/OkHttp: F~�ם!̽>����um��e��_���3������nU�p�US�/i��]Iri6�E��HZY�:Z��j 2X?�sެ��w�♬�J����`���i���t��50P��@��A:�O���rg�hU5We��t���ׯ_�>��������s�G�\Ϫ?^��ye>���3�k�iT�U����&�ٟ�^��0��L��"��u�J�n��=�`�=s�U2��[�$���f��)PIi�8s�������3�w��7��R�䵹Q����2�y]�{���Z<5�ڿ6{2��=��|8��p�Sw������s{�*���v���_���\���~V��.���Z�@��)N«^q���*�tWmԵ8��w�jI�]��j��fQ^�WU��u/D(}2�`콓�}���GC�V���Q�T��Vu��T�!���Y��&@�Vx����ģuC��~���S�3�C��<���M�h_�g�u���4p��o�|�����,F{����kY}�� �?Q�إ;V
Here is what I get when did from postman
I have tried with a different solution in StackOverflow flow. But nothing works for me. And this is the first time I am posting a question. So please forgive the mistakes and help me to improve.