Spring gets Null values from Retrofit











up vote
0
down vote

favorite












I am trying to send POST Request from Android to Spring via Retrofit from past 2 days. I have tried plenty of solutions regarding this, but nothing seems to be working. So, asking here finally to be able to get some help.



So, i am trying to send a simple Object from Android to Spring via retrofit. From android side i have verified the values sent by me and it gives me correct value.(I have debugged it via Android's debugging mode). But on spring side i got null values.



This is my code ->



function foo() -> from which i am sending my request.



 private void foo() {
request.setName1("XYZ");
request.setName2("PQR");
Api.upload(request, new Callback<BasicResponse>() {
@Override
public void onResponse(Call<BasicResponse> call, Response<BasicResponse> response) {
Log.d(TAG, "onResponse: Success" + response.toString());
}

@Override
public void onFailure(Call<BasicResponse> call, Throwable t) {
Log.d(TAG, "onResponse: Failure");
}
});
}
}


my upload Function ->



public static void upload(Request request, Callback<BasicResponse> callback) {
uploadRequest api = retrofit.create(uploadRequest.class);
Call<BasicResponse> call = uploadRequest.uploadCall(POJO);
call.enqueue(callback);
}


This is my UploadRequest Interface ->



 public interface uploadRequest{
@POST(UPLOAD_REQUEST)
Call<BasicResponse> uploadCall(@Body POJO pojo);
}


This is My POJO Class



public class POJO {

private String Name1;
private String Name2;

public String getName1() {
return Name1;
}

public void setName1(String name1) {
Name1 = name1;
}

public String getName2() {
return Name2;
}

public void setName2(String name2) {
Name2 = name2;
}
}


And this is my Spring Controller Method



@RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json")
@ResponseBody
public void UploadImage(@RequestBody POJO pojo,HttpServletRequest request) {
if(pojo!=null){
System.out.println("pojo is not null");
System.out.println(pojo.getName1());
}
else{
System.out.println("null");
}
}


I am getting pojo is not null and inside the pojo.getName1(), the value prints is null.



Edit : Adding BasicResponse Class.



public class BasicResponse {

private boolean success = Boolean.TRUE;
private ErrorCode errorCode;
private String response;
private Integer totalCount;
private String callingUserId;

public BasicResponse() {
super();
}

public boolean isSuccess() {
return success;
}

public void setSuccess(boolean success) {
this.success = success;
}

public ErrorCode getErrorCode() {
return errorCode;
}

public void setErrorCode(ErrorCode errorCode) {
this.errorCode = errorCode;
this.success = false;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public void setResponse(Object response) {
if (response != null) {
this.response = GsonUtils.toGson(response);
}
}

public Integer getTotalCount() {
return totalCount;
}

public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}

public String getCallingUserId() {
return callingUserId;
}

public void setCallingUserId(String callingUserId) {
this.callingUserId = callingUserId;
}
}









share|improve this question
























  • Can you show a sample of response?
    – tm13
    Nov 18 at 14:17










  • @tm13 on spring side it's printing pojo is not null and null, which means that pojo object received by my code is not null/
    – Avi Patel
    Nov 18 at 14:19

















up vote
0
down vote

favorite












I am trying to send POST Request from Android to Spring via Retrofit from past 2 days. I have tried plenty of solutions regarding this, but nothing seems to be working. So, asking here finally to be able to get some help.



So, i am trying to send a simple Object from Android to Spring via retrofit. From android side i have verified the values sent by me and it gives me correct value.(I have debugged it via Android's debugging mode). But on spring side i got null values.



This is my code ->



function foo() -> from which i am sending my request.



 private void foo() {
request.setName1("XYZ");
request.setName2("PQR");
Api.upload(request, new Callback<BasicResponse>() {
@Override
public void onResponse(Call<BasicResponse> call, Response<BasicResponse> response) {
Log.d(TAG, "onResponse: Success" + response.toString());
}

@Override
public void onFailure(Call<BasicResponse> call, Throwable t) {
Log.d(TAG, "onResponse: Failure");
}
});
}
}


my upload Function ->



public static void upload(Request request, Callback<BasicResponse> callback) {
uploadRequest api = retrofit.create(uploadRequest.class);
Call<BasicResponse> call = uploadRequest.uploadCall(POJO);
call.enqueue(callback);
}


This is my UploadRequest Interface ->



 public interface uploadRequest{
@POST(UPLOAD_REQUEST)
Call<BasicResponse> uploadCall(@Body POJO pojo);
}


This is My POJO Class



public class POJO {

private String Name1;
private String Name2;

public String getName1() {
return Name1;
}

public void setName1(String name1) {
Name1 = name1;
}

public String getName2() {
return Name2;
}

public void setName2(String name2) {
Name2 = name2;
}
}


And this is my Spring Controller Method



@RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json")
@ResponseBody
public void UploadImage(@RequestBody POJO pojo,HttpServletRequest request) {
if(pojo!=null){
System.out.println("pojo is not null");
System.out.println(pojo.getName1());
}
else{
System.out.println("null");
}
}


I am getting pojo is not null and inside the pojo.getName1(), the value prints is null.



Edit : Adding BasicResponse Class.



public class BasicResponse {

private boolean success = Boolean.TRUE;
private ErrorCode errorCode;
private String response;
private Integer totalCount;
private String callingUserId;

public BasicResponse() {
super();
}

public boolean isSuccess() {
return success;
}

public void setSuccess(boolean success) {
this.success = success;
}

public ErrorCode getErrorCode() {
return errorCode;
}

public void setErrorCode(ErrorCode errorCode) {
this.errorCode = errorCode;
this.success = false;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public void setResponse(Object response) {
if (response != null) {
this.response = GsonUtils.toGson(response);
}
}

public Integer getTotalCount() {
return totalCount;
}

public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}

public String getCallingUserId() {
return callingUserId;
}

public void setCallingUserId(String callingUserId) {
this.callingUserId = callingUserId;
}
}









share|improve this question
























  • Can you show a sample of response?
    – tm13
    Nov 18 at 14:17










  • @tm13 on spring side it's printing pojo is not null and null, which means that pojo object received by my code is not null/
    – Avi Patel
    Nov 18 at 14:19















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to send POST Request from Android to Spring via Retrofit from past 2 days. I have tried plenty of solutions regarding this, but nothing seems to be working. So, asking here finally to be able to get some help.



So, i am trying to send a simple Object from Android to Spring via retrofit. From android side i have verified the values sent by me and it gives me correct value.(I have debugged it via Android's debugging mode). But on spring side i got null values.



This is my code ->



function foo() -> from which i am sending my request.



 private void foo() {
request.setName1("XYZ");
request.setName2("PQR");
Api.upload(request, new Callback<BasicResponse>() {
@Override
public void onResponse(Call<BasicResponse> call, Response<BasicResponse> response) {
Log.d(TAG, "onResponse: Success" + response.toString());
}

@Override
public void onFailure(Call<BasicResponse> call, Throwable t) {
Log.d(TAG, "onResponse: Failure");
}
});
}
}


my upload Function ->



public static void upload(Request request, Callback<BasicResponse> callback) {
uploadRequest api = retrofit.create(uploadRequest.class);
Call<BasicResponse> call = uploadRequest.uploadCall(POJO);
call.enqueue(callback);
}


This is my UploadRequest Interface ->



 public interface uploadRequest{
@POST(UPLOAD_REQUEST)
Call<BasicResponse> uploadCall(@Body POJO pojo);
}


This is My POJO Class



public class POJO {

private String Name1;
private String Name2;

public String getName1() {
return Name1;
}

public void setName1(String name1) {
Name1 = name1;
}

public String getName2() {
return Name2;
}

public void setName2(String name2) {
Name2 = name2;
}
}


And this is my Spring Controller Method



@RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json")
@ResponseBody
public void UploadImage(@RequestBody POJO pojo,HttpServletRequest request) {
if(pojo!=null){
System.out.println("pojo is not null");
System.out.println(pojo.getName1());
}
else{
System.out.println("null");
}
}


I am getting pojo is not null and inside the pojo.getName1(), the value prints is null.



Edit : Adding BasicResponse Class.



public class BasicResponse {

private boolean success = Boolean.TRUE;
private ErrorCode errorCode;
private String response;
private Integer totalCount;
private String callingUserId;

public BasicResponse() {
super();
}

public boolean isSuccess() {
return success;
}

public void setSuccess(boolean success) {
this.success = success;
}

public ErrorCode getErrorCode() {
return errorCode;
}

public void setErrorCode(ErrorCode errorCode) {
this.errorCode = errorCode;
this.success = false;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public void setResponse(Object response) {
if (response != null) {
this.response = GsonUtils.toGson(response);
}
}

public Integer getTotalCount() {
return totalCount;
}

public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}

public String getCallingUserId() {
return callingUserId;
}

public void setCallingUserId(String callingUserId) {
this.callingUserId = callingUserId;
}
}









share|improve this question















I am trying to send POST Request from Android to Spring via Retrofit from past 2 days. I have tried plenty of solutions regarding this, but nothing seems to be working. So, asking here finally to be able to get some help.



So, i am trying to send a simple Object from Android to Spring via retrofit. From android side i have verified the values sent by me and it gives me correct value.(I have debugged it via Android's debugging mode). But on spring side i got null values.



This is my code ->



function foo() -> from which i am sending my request.



 private void foo() {
request.setName1("XYZ");
request.setName2("PQR");
Api.upload(request, new Callback<BasicResponse>() {
@Override
public void onResponse(Call<BasicResponse> call, Response<BasicResponse> response) {
Log.d(TAG, "onResponse: Success" + response.toString());
}

@Override
public void onFailure(Call<BasicResponse> call, Throwable t) {
Log.d(TAG, "onResponse: Failure");
}
});
}
}


my upload Function ->



public static void upload(Request request, Callback<BasicResponse> callback) {
uploadRequest api = retrofit.create(uploadRequest.class);
Call<BasicResponse> call = uploadRequest.uploadCall(POJO);
call.enqueue(callback);
}


This is my UploadRequest Interface ->



 public interface uploadRequest{
@POST(UPLOAD_REQUEST)
Call<BasicResponse> uploadCall(@Body POJO pojo);
}


This is My POJO Class



public class POJO {

private String Name1;
private String Name2;

public String getName1() {
return Name1;
}

public void setName1(String name1) {
Name1 = name1;
}

public String getName2() {
return Name2;
}

public void setName2(String name2) {
Name2 = name2;
}
}


And this is my Spring Controller Method



@RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json")
@ResponseBody
public void UploadImage(@RequestBody POJO pojo,HttpServletRequest request) {
if(pojo!=null){
System.out.println("pojo is not null");
System.out.println(pojo.getName1());
}
else{
System.out.println("null");
}
}


I am getting pojo is not null and inside the pojo.getName1(), the value prints is null.



Edit : Adding BasicResponse Class.



public class BasicResponse {

private boolean success = Boolean.TRUE;
private ErrorCode errorCode;
private String response;
private Integer totalCount;
private String callingUserId;

public BasicResponse() {
super();
}

public boolean isSuccess() {
return success;
}

public void setSuccess(boolean success) {
this.success = success;
}

public ErrorCode getErrorCode() {
return errorCode;
}

public void setErrorCode(ErrorCode errorCode) {
this.errorCode = errorCode;
this.success = false;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public void setResponse(Object response) {
if (response != null) {
this.response = GsonUtils.toGson(response);
}
}

public Integer getTotalCount() {
return totalCount;
}

public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}

public String getCallingUserId() {
return callingUserId;
}

public void setCallingUserId(String callingUserId) {
this.callingUserId = callingUserId;
}
}






java android spring retrofit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 at 14:50

























asked Nov 18 at 14:13









Avi Patel

809




809












  • Can you show a sample of response?
    – tm13
    Nov 18 at 14:17










  • @tm13 on spring side it's printing pojo is not null and null, which means that pojo object received by my code is not null/
    – Avi Patel
    Nov 18 at 14:19




















  • Can you show a sample of response?
    – tm13
    Nov 18 at 14:17










  • @tm13 on spring side it's printing pojo is not null and null, which means that pojo object received by my code is not null/
    – Avi Patel
    Nov 18 at 14:19


















Can you show a sample of response?
– tm13
Nov 18 at 14:17




Can you show a sample of response?
– tm13
Nov 18 at 14:17












@tm13 on spring side it's printing pojo is not null and null, which means that pojo object received by my code is not null/
– Avi Patel
Nov 18 at 14:19






@tm13 on spring side it's printing pojo is not null and null, which means that pojo object received by my code is not null/
– Avi Patel
Nov 18 at 14:19














2 Answers
2






active

oldest

votes

















up vote
1
down vote













Compare the response and your POJO class. The instance variables of your POJO class must be the same as in response. In your case Name1 and Name2. If they are name1, name2 in the response (which means if they do not start with capital letters, etc.), or different, it gives you NullPointerException.






share|improve this answer





















  • So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
    – Avi Patel
    Nov 18 at 14:35












  • Can you comment or edit your answer to show one example of your JSON response? It would be more clear
    – tm13
    Nov 18 at 14:47












  • Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
    – Avi Patel
    Nov 18 at 14:49




















up vote
0
down vote













Most likely Name1 and Name2 have different names in json than in your POJO and Jackson, with is used under the hood when you annotate your parameters with @RequestBody can not figure them out, so you get null values. Check out your json.






share|improve this answer





















  • i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
    – Avi Patel
    Nov 18 at 14:44












  • @RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
    – Igor
    Nov 18 at 14:53










  • Sorry for formatting, but you propably get the idea
    – Igor
    Nov 18 at 14:53










  • I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
    – Avi Patel
    Nov 18 at 14:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361820%2fspring-gets-null-values-from-retrofit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Compare the response and your POJO class. The instance variables of your POJO class must be the same as in response. In your case Name1 and Name2. If they are name1, name2 in the response (which means if they do not start with capital letters, etc.), or different, it gives you NullPointerException.






share|improve this answer





















  • So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
    – Avi Patel
    Nov 18 at 14:35












  • Can you comment or edit your answer to show one example of your JSON response? It would be more clear
    – tm13
    Nov 18 at 14:47












  • Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
    – Avi Patel
    Nov 18 at 14:49

















up vote
1
down vote













Compare the response and your POJO class. The instance variables of your POJO class must be the same as in response. In your case Name1 and Name2. If they are name1, name2 in the response (which means if they do not start with capital letters, etc.), or different, it gives you NullPointerException.






share|improve this answer





















  • So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
    – Avi Patel
    Nov 18 at 14:35












  • Can you comment or edit your answer to show one example of your JSON response? It would be more clear
    – tm13
    Nov 18 at 14:47












  • Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
    – Avi Patel
    Nov 18 at 14:49















up vote
1
down vote










up vote
1
down vote









Compare the response and your POJO class. The instance variables of your POJO class must be the same as in response. In your case Name1 and Name2. If they are name1, name2 in the response (which means if they do not start with capital letters, etc.), or different, it gives you NullPointerException.






share|improve this answer












Compare the response and your POJO class. The instance variables of your POJO class must be the same as in response. In your case Name1 and Name2. If they are name1, name2 in the response (which means if they do not start with capital letters, etc.), or different, it gives you NullPointerException.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 at 14:30









tm13

476119




476119












  • So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
    – Avi Patel
    Nov 18 at 14:35












  • Can you comment or edit your answer to show one example of your JSON response? It would be more clear
    – tm13
    Nov 18 at 14:47












  • Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
    – Avi Patel
    Nov 18 at 14:49




















  • So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
    – Avi Patel
    Nov 18 at 14:35












  • Can you comment or edit your answer to show one example of your JSON response? It would be more clear
    – tm13
    Nov 18 at 14:47












  • Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
    – Avi Patel
    Nov 18 at 14:49


















So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
– Avi Patel
Nov 18 at 14:35






So, you are saying that the my BasicResponse and POJO class should be the same? If you are saying that the POJO class on Android side and Spring side should be the same then they are same.
– Avi Patel
Nov 18 at 14:35














Can you comment or edit your answer to show one example of your JSON response? It would be more clear
– tm13
Nov 18 at 14:47






Can you comment or edit your answer to show one example of your JSON response? It would be more clear
– tm13
Nov 18 at 14:47














Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
– Avi Patel
Nov 18 at 14:49






Basic Response is just a class with Method that returns String that one whats to return. @tm13 added BasicResponse class.
– Avi Patel
Nov 18 at 14:49














up vote
0
down vote













Most likely Name1 and Name2 have different names in json than in your POJO and Jackson, with is used under the hood when you annotate your parameters with @RequestBody can not figure them out, so you get null values. Check out your json.






share|improve this answer





















  • i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
    – Avi Patel
    Nov 18 at 14:44












  • @RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
    – Igor
    Nov 18 at 14:53










  • Sorry for formatting, but you propably get the idea
    – Igor
    Nov 18 at 14:53










  • I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
    – Avi Patel
    Nov 18 at 14:56















up vote
0
down vote













Most likely Name1 and Name2 have different names in json than in your POJO and Jackson, with is used under the hood when you annotate your parameters with @RequestBody can not figure them out, so you get null values. Check out your json.






share|improve this answer





















  • i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
    – Avi Patel
    Nov 18 at 14:44












  • @RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
    – Igor
    Nov 18 at 14:53










  • Sorry for formatting, but you propably get the idea
    – Igor
    Nov 18 at 14:53










  • I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
    – Avi Patel
    Nov 18 at 14:56













up vote
0
down vote










up vote
0
down vote









Most likely Name1 and Name2 have different names in json than in your POJO and Jackson, with is used under the hood when you annotate your parameters with @RequestBody can not figure them out, so you get null values. Check out your json.






share|improve this answer












Most likely Name1 and Name2 have different names in json than in your POJO and Jackson, with is used under the hood when you annotate your parameters with @RequestBody can not figure them out, so you get null values. Check out your json.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 at 14:43









Igor

864




864












  • i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
    – Avi Patel
    Nov 18 at 14:44












  • @RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
    – Igor
    Nov 18 at 14:53










  • Sorry for formatting, but you propably get the idea
    – Igor
    Nov 18 at 14:53










  • I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
    – Avi Patel
    Nov 18 at 14:56


















  • i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
    – Avi Patel
    Nov 18 at 14:44












  • @RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
    – Igor
    Nov 18 at 14:53










  • Sorry for formatting, but you propably get the idea
    – Igor
    Nov 18 at 14:53










  • I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
    – Avi Patel
    Nov 18 at 14:56
















i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
– Avi Patel
Nov 18 at 14:44






i am using gson, not Jsckson. can you tell me how can i check my JSON on Spring side?
– Avi Patel
Nov 18 at 14:44














@RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
– Igor
Nov 18 at 14:53




@RequestMapping(value = "/UploadRequest",method = RequestMethod.POST,consumes = "application/json", produces = "application/json") @ResponseBody public void UploadImage(@RequestBody String pojo,HttpServletRequest request) { System.out.println(pojo); }
– Igor
Nov 18 at 14:53












Sorry for formatting, but you propably get the idea
– Igor
Nov 18 at 14:53




Sorry for formatting, but you propably get the idea
– Igor
Nov 18 at 14:53












I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
– Avi Patel
Nov 18 at 14:56




I have Returned the POJO class with basicResponse.setResponse(cropImageRequest); and it returns {} "Empty JSON", however i have also provided the method to check if object is null or not inside UploadImage Function, and in that function it's not null. :(
– Avi Patel
Nov 18 at 14:56


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361820%2fspring-gets-null-values-from-retrofit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin