Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Changing http response status code when exception occurs in Workbench process

Avatar

Avatar
Establish
Level 2
manu-gupta
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

1 solution
Top badges earned
Establish
View profile

Avatar
Establish
Level 2
manu-gupta
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

1 solution
Top badges earned
Establish
View profile
manu-gupta
Level 2

07-10-2019

Hi,

Did anyone try changing HTTP Status COde from 200 to 4XX or 5XX in process in case OOB event for exception is triggered?

I have created process in Workbench where we are consuming JSON as body input and passing it through few business specific exceptions and OOB provided Exceptions like FileUtilsExceptions, Since processis invoked correctly but some validation failure or file operations failure can we pass the response with error description and HTTP STATUS code to != 200

Any pointers

AEM 6.2 on JBOSS

WorkBench 6.2

Manu

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar
Establish
Level 2
manu-gupta
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

1 solution
Top badges earned
Establish
View profile

Avatar
Establish
Level 2
manu-gupta
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

1 solution
Top badges earned
Establish
View profile
manu-gupta
Level 2

16-10-2019

thanks, I got solution by not handling exception (routing to SetValue operation and setting custom error response) instead I left process to show real error as text/HTML response with http status code 500.

This is a work around as for every error in process we are getting 500 http status code and we cannot override with our custom response.

Avatar

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

309 likes

Total Posts

1,131 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

309 likes

Total Posts

1,131 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile
Mayank_Gandhi
Level 10

09-10-2019

Why not create a variable to map HTTP status code in separately. Based on a conditional check do a set value to the custom variable for HTTP response code similar to the exception.

Avatar

Avatar
Establish
Level 2
manu-gupta
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

1 solution
Top badges earned
Establish
View profile

Avatar
Establish
Level 2
manu-gupta
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

1 solution
Top badges earned
Establish
View profile
manu-gupta
Level 2

08-10-2019

Hi Mayank,

Since we know event is triggered on Exception, which I assign to SetValue operation in variable as self defined error string with description. But some how I cannot change the http status code.

So need pointers on that

Manu

Avatar

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

309 likes

Total Posts

1,131 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

309 likes

Total Posts

1,131 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile
Mayank_Gandhi
Level 10

08-10-2019

"we pass the response with error description and HTTP STATUS code", please explain how are you doing this so that we can share some inputs.