Grails frontend with JAVA Springboot backend: API call throwing RestClientException while backend API is...
This is kind of my first time working with Grails.
Frontend codebase where API call is made -
try{
def serviceResponse = restClient.post(
path: "/api/endpoint",
headers:['Authorization': "Bearer "+sCtx.accessToken]){
type "application/x-www-form-urlencoded"
charset "UTF-8"
urlenc
"interval":interval,"type":typeVal,"value":value,"count":count, "perTxnLimit":perTxnLimit
}
}catch (RESTClientException ex) {
println 'exception resp '+ex?.response?.statusMessage
println 'badResponse==' + ex?.response?.statusCode //404
println 'response body==' + ex?.response?.contentAsString //or for raw bytes use ex.response.data
def errJson = JSON.parse (ex?.response?.contentAsString )//or for raw bytes use ex.response.data
true?.json
}
Output of above code in GGTS (Groovy/grails Tool Suite) console -
exception resp OK
badResponse==200
response body==true
I have no idea where/why is this exception coming, even though status is 200 which means OK. Also, the backend API is doing the db change it is supposed to do.
Response from logs of backend Springboot project (API responds with boolean true) -
143 > POST http://backend/api/endpoint
143 > Accept: */*
143 > accept-encoding: gzip, deflate
143 > Authorization: Bearer <auth>
143 > Connection: close
143 > Content-Length: 53
143 > Content-Type: application/x-www-form-urlencoded
143 > Host: somedomain.com
143 > Postman-Token: cc3dd170-3f6e-4c29-b734-15722e3035d5
143 > User-Agent: PostmanRuntime/7.4.0
143 > X-Forwarded-For: 115.112.95.170, 10.30.1.141
143 > X-Forwarded-Host: somedomain.com
143 > X-Forwarded-Port: 443
143 > X-Forwarded-Proto: https
143 > X-Forwarded-Server: somedomain.com
2018-11-25 12:41:52,407 12403930 [XNIO-3 task-3] INFO [LoggingFilter.java:155] - 80 * Server responded with a response on thread XNIO-3 task-3
80 < 200
80 < Content-Type: application/json
Backend codebase -
@Path("api/endpoint")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public boolean customerInducedLimit(@FormParam("type") String type, @FormParam("interval") String interval, @BeanParam CustomerInducedLimitReqDto dto,
@Context SecurityContext security) {
try{
return inducedLimitService.createOrUpdateInducedLimit(uuid,type, interval, dto);
} catch(InvalidInputException ex){
logger.error("invalid parameters");
return false;
} catch(AccountNotFoundException ex){
logger.error("Account not found exception");
return false;
} catch(Exception e){
logger.error("Exception occured while processing customer induced limits");
return false;
}
}
java spring-boot exception grails
add a comment |
This is kind of my first time working with Grails.
Frontend codebase where API call is made -
try{
def serviceResponse = restClient.post(
path: "/api/endpoint",
headers:['Authorization': "Bearer "+sCtx.accessToken]){
type "application/x-www-form-urlencoded"
charset "UTF-8"
urlenc
"interval":interval,"type":typeVal,"value":value,"count":count, "perTxnLimit":perTxnLimit
}
}catch (RESTClientException ex) {
println 'exception resp '+ex?.response?.statusMessage
println 'badResponse==' + ex?.response?.statusCode //404
println 'response body==' + ex?.response?.contentAsString //or for raw bytes use ex.response.data
def errJson = JSON.parse (ex?.response?.contentAsString )//or for raw bytes use ex.response.data
true?.json
}
Output of above code in GGTS (Groovy/grails Tool Suite) console -
exception resp OK
badResponse==200
response body==true
I have no idea where/why is this exception coming, even though status is 200 which means OK. Also, the backend API is doing the db change it is supposed to do.
Response from logs of backend Springboot project (API responds with boolean true) -
143 > POST http://backend/api/endpoint
143 > Accept: */*
143 > accept-encoding: gzip, deflate
143 > Authorization: Bearer <auth>
143 > Connection: close
143 > Content-Length: 53
143 > Content-Type: application/x-www-form-urlencoded
143 > Host: somedomain.com
143 > Postman-Token: cc3dd170-3f6e-4c29-b734-15722e3035d5
143 > User-Agent: PostmanRuntime/7.4.0
143 > X-Forwarded-For: 115.112.95.170, 10.30.1.141
143 > X-Forwarded-Host: somedomain.com
143 > X-Forwarded-Port: 443
143 > X-Forwarded-Proto: https
143 > X-Forwarded-Server: somedomain.com
2018-11-25 12:41:52,407 12403930 [XNIO-3 task-3] INFO [LoggingFilter.java:155] - 80 * Server responded with a response on thread XNIO-3 task-3
80 < 200
80 < Content-Type: application/json
Backend codebase -
@Path("api/endpoint")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public boolean customerInducedLimit(@FormParam("type") String type, @FormParam("interval") String interval, @BeanParam CustomerInducedLimitReqDto dto,
@Context SecurityContext security) {
try{
return inducedLimitService.createOrUpdateInducedLimit(uuid,type, interval, dto);
} catch(InvalidInputException ex){
logger.error("invalid parameters");
return false;
} catch(AccountNotFoundException ex){
logger.error("Account not found exception");
return false;
} catch(Exception e){
logger.error("Exception occured while processing customer induced limits");
return false;
}
}
java spring-boot exception grails
hasex.message
any clues?
– cfrick
Nov 19 '18 at 18:01
add a comment |
This is kind of my first time working with Grails.
Frontend codebase where API call is made -
try{
def serviceResponse = restClient.post(
path: "/api/endpoint",
headers:['Authorization': "Bearer "+sCtx.accessToken]){
type "application/x-www-form-urlencoded"
charset "UTF-8"
urlenc
"interval":interval,"type":typeVal,"value":value,"count":count, "perTxnLimit":perTxnLimit
}
}catch (RESTClientException ex) {
println 'exception resp '+ex?.response?.statusMessage
println 'badResponse==' + ex?.response?.statusCode //404
println 'response body==' + ex?.response?.contentAsString //or for raw bytes use ex.response.data
def errJson = JSON.parse (ex?.response?.contentAsString )//or for raw bytes use ex.response.data
true?.json
}
Output of above code in GGTS (Groovy/grails Tool Suite) console -
exception resp OK
badResponse==200
response body==true
I have no idea where/why is this exception coming, even though status is 200 which means OK. Also, the backend API is doing the db change it is supposed to do.
Response from logs of backend Springboot project (API responds with boolean true) -
143 > POST http://backend/api/endpoint
143 > Accept: */*
143 > accept-encoding: gzip, deflate
143 > Authorization: Bearer <auth>
143 > Connection: close
143 > Content-Length: 53
143 > Content-Type: application/x-www-form-urlencoded
143 > Host: somedomain.com
143 > Postman-Token: cc3dd170-3f6e-4c29-b734-15722e3035d5
143 > User-Agent: PostmanRuntime/7.4.0
143 > X-Forwarded-For: 115.112.95.170, 10.30.1.141
143 > X-Forwarded-Host: somedomain.com
143 > X-Forwarded-Port: 443
143 > X-Forwarded-Proto: https
143 > X-Forwarded-Server: somedomain.com
2018-11-25 12:41:52,407 12403930 [XNIO-3 task-3] INFO [LoggingFilter.java:155] - 80 * Server responded with a response on thread XNIO-3 task-3
80 < 200
80 < Content-Type: application/json
Backend codebase -
@Path("api/endpoint")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public boolean customerInducedLimit(@FormParam("type") String type, @FormParam("interval") String interval, @BeanParam CustomerInducedLimitReqDto dto,
@Context SecurityContext security) {
try{
return inducedLimitService.createOrUpdateInducedLimit(uuid,type, interval, dto);
} catch(InvalidInputException ex){
logger.error("invalid parameters");
return false;
} catch(AccountNotFoundException ex){
logger.error("Account not found exception");
return false;
} catch(Exception e){
logger.error("Exception occured while processing customer induced limits");
return false;
}
}
java spring-boot exception grails
This is kind of my first time working with Grails.
Frontend codebase where API call is made -
try{
def serviceResponse = restClient.post(
path: "/api/endpoint",
headers:['Authorization': "Bearer "+sCtx.accessToken]){
type "application/x-www-form-urlencoded"
charset "UTF-8"
urlenc
"interval":interval,"type":typeVal,"value":value,"count":count, "perTxnLimit":perTxnLimit
}
}catch (RESTClientException ex) {
println 'exception resp '+ex?.response?.statusMessage
println 'badResponse==' + ex?.response?.statusCode //404
println 'response body==' + ex?.response?.contentAsString //or for raw bytes use ex.response.data
def errJson = JSON.parse (ex?.response?.contentAsString )//or for raw bytes use ex.response.data
true?.json
}
Output of above code in GGTS (Groovy/grails Tool Suite) console -
exception resp OK
badResponse==200
response body==true
I have no idea where/why is this exception coming, even though status is 200 which means OK. Also, the backend API is doing the db change it is supposed to do.
Response from logs of backend Springboot project (API responds with boolean true) -
143 > POST http://backend/api/endpoint
143 > Accept: */*
143 > accept-encoding: gzip, deflate
143 > Authorization: Bearer <auth>
143 > Connection: close
143 > Content-Length: 53
143 > Content-Type: application/x-www-form-urlencoded
143 > Host: somedomain.com
143 > Postman-Token: cc3dd170-3f6e-4c29-b734-15722e3035d5
143 > User-Agent: PostmanRuntime/7.4.0
143 > X-Forwarded-For: 115.112.95.170, 10.30.1.141
143 > X-Forwarded-Host: somedomain.com
143 > X-Forwarded-Port: 443
143 > X-Forwarded-Proto: https
143 > X-Forwarded-Server: somedomain.com
2018-11-25 12:41:52,407 12403930 [XNIO-3 task-3] INFO [LoggingFilter.java:155] - 80 * Server responded with a response on thread XNIO-3 task-3
80 < 200
80 < Content-Type: application/json
Backend codebase -
@Path("api/endpoint")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public boolean customerInducedLimit(@FormParam("type") String type, @FormParam("interval") String interval, @BeanParam CustomerInducedLimitReqDto dto,
@Context SecurityContext security) {
try{
return inducedLimitService.createOrUpdateInducedLimit(uuid,type, interval, dto);
} catch(InvalidInputException ex){
logger.error("invalid parameters");
return false;
} catch(AccountNotFoundException ex){
logger.error("Account not found exception");
return false;
} catch(Exception e){
logger.error("Exception occured while processing customer induced limits");
return false;
}
}
java spring-boot exception grails
java spring-boot exception grails
asked Nov 19 '18 at 17:35
Sandeepan NathSandeepan Nath
3,514144899
3,514144899
hasex.message
any clues?
– cfrick
Nov 19 '18 at 18:01
add a comment |
hasex.message
any clues?
– cfrick
Nov 19 '18 at 18:01
has
ex.message
any clues?– cfrick
Nov 19 '18 at 18:01
has
ex.message
any clues?– cfrick
Nov 19 '18 at 18:01
add a comment |
0
active
oldest
votes
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379925%2fgrails-frontend-with-java-springboot-backend-api-call-throwing-restclientexcept%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379925%2fgrails-frontend-with-java-springboot-backend-api-call-throwing-restclientexcept%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
has
ex.message
any clues?– cfrick
Nov 19 '18 at 18:01