Client error 422 Unprocessable Entity (SimplisticHttpGetGateWay.java [taskScheduler-17])

Dear Community,
I am getting this error when I want to send an SMS message:

Mar 27 06:31:46 hmis tomcat9[286]: * INFO 2023-03-27 06:31:46,727 [Level: INFO, category: SMS_SEND, time: Mon Mar 27 06:31:46 UTC 2023, message: Sending SMS] (InMemoryNotifier.java [taskScheduler-17])
Mar 27 06:31:46 hmis tomcat9[286]: * INFO 2023-03-27 06:31:46,728 Sending SMS to [23276710495] (SmsMessageSender.java [taskScheduler-17])
Mar 27 06:31:46 hmis tomcat9[286]: * ERROR 2023-03-27 06:31:46,777 Client error 422 Unprocessable Entity (SimplisticHttpGetGateWay.java [taskScheduler-17])
Mar 27 06:31:46 hmis tomcat9[286]: * ERROR 2023-03-27 06:31:46,778 SMS failed, failure cause: failed (SmsMessageSender.java [taskScheduler-17])
Mar 27 06:31:46 hmis tomcat9[286]: * INFO 2023-03-27 06:31:46,778 [Level: INFO, category: SMS_SEND, time: Mon Mar 27 06:31:46 UTC 2023, message: Message sending failed] (InMemoryNotifier.java [taskScheduler-17])

Please can someone help

@zubair ?

1 Like

Could be related to:

Please check @zubair 's messages for the additional info to share and the final solution. Thanks!

Dears,
We already worked on the SMS gateway and we are assuming it is working fine. On the DHIS2 side, I deleted the SMS configuration and reboot the server. The server came up and on the logs, it indicated that the SMS gateway was not configured. So I configured the gateway and set it as the default. On the log all these indications were available but then with a piece of extra information which is an error:

Error
**Apr 21 18:15:03 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:03,318 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@5f1ea06] (DefaultGatewayAdministrationService.java [tomcat-http-10])**
**Apr 21 18:15:03 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:03,318 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@5f1ea06] (DefaultGatewayAdministrationService.java [tomcat-http-10])**
**Apr 21 18:15:05 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:05,971 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@3ee856dc] (DefaultGatewayAdministrationService.java [tomcat-http-9])**
**Apr 21 18:15:06 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:06,204 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@7705f6d9] (DefaultGatewayAdministrationService.java [tomcat-http-5])**
**Apr 21 18:15:05 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:05,971 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@3ee856dc] (DefaultGatewayAdministrationService.java [tomcat-http-9])**
**Apr 21 18:15:06 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:06,204 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@7705f6d9] (DefaultGatewayAdministrationService.java [tomcat-http-5])**
**Apr 21 18:15:06 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:06,380 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@454ffaa6] (DefaultGatewayAdministrationService.java [tomcat-http-4])**
**Apr 21 18:15:06 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:06,616 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@481f35ac] (DefaultGatewayAdministrationService.java [tomcat-http-7])**
**Apr 21 18:15:06 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:06,380 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@454ffaa6] (DefaultGatewayAdministrationService.java [tomcat-http-4])**
**Apr 21 18:15:06 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:06,616 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@481f35ac] (DefaultGatewayAdministrationService.java [tomcat-http-7])**
**Apr 21 18:15:07 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:07,030 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@49f69e5c] (DefaultGatewayAdministrationService.java [tomcat-http-1])**
**Apr 21 18:15:07 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:07,030 Gateway configuration found: [org.hisp.dhis.sms.config.GenericHttpGatewayConfig@49f69e5c] (DefaultGatewayAdministrationService.java [tomcat-http-1])**

**Apr 21 18:15:38 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:38,107 MoH RapidPro SMPP Gateway is set as default gateway (UpdateDefaultGatewayAction.java [tomcat-http-4])**
**Apr 21 18:15:38 hmis tomcat9[52774]: * INFO  2023-04-21 18:15:38,107 MoH RapidPro SMPP Gateway is set as default gateway (UpdateDefaultGatewayAction.java [tomcat-http-4])**
**Apr 21 18:15:44 hmis tomcat9[52774]: * ERROR 2023-04-21 18:15:44,205 Initialised statement manager (StatementInterceptor.java [tomcat-http-7])**
**Apr 21 18:15:44 hmis tomcat9[52774]: * ERROR 2023-04-21 18:15:44,205 Initialised statement manager (StatementInterceptor.java [tomcat-http-7])**

Please what is the statement manager error?

When i further try to test ignoring the error, I am having this:

Error

pr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,101 Scheduler initiated execution of job: Vg9cgqtZUyQ, processingSendSmsAction, SMS_SEND, null (DefaultSchedulingManager.java [tomcat-http-7])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,127 [Level: INFO, category: SMS_SEND, time: Fri Apr 21 18:48:28 UTC 2023, message: Sending SMS] (InMemoryNotifier.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,133 Sending SMS to [23276710495] (SmsMessageSender.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * ERROR 2023-04-21 18:48:28,298 Client error 422 Unprocessable Entity (SimplisticHttpGetGateWay.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * ERROR 2023-04-21 18:48:28,299 SMS failed, failure cause: failed (SmsMessageSender.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,299 [Level: INFO, category: SMS_SEND, time: Fri Apr 21 18:48:28 UTC 2023, message: Message sending failed] (InMemoryNotifier.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,300 ‘system-process’ create org.hisp.dhis.sms.outbound.OutboundSms (AuditLogUtil.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,101 Scheduler initiated execution of job: Vg9cgqtZUyQ, processingSendSmsAction, SMS_SEND, null (DefaultSchedulingManager.java [tomcat-http-7])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,127 [Level: INFO, category: SMS_SEND, time: Fri Apr 21 18:48:28 UTC 2023, message: Sending SMS] (InMemoryNotifier.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,133 Sending SMS to [23276710495] (SmsMessageSender.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * ERROR 2023-04-21 18:48:28,298 Client error 422 Unprocessable Entity (SimplisticHttpGetGateWay.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * ERROR 2023-04-21 18:48:28,299 SMS failed, failure cause: failed (SmsMessageSender.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,299 [Level: INFO, category: SMS_SEND, time: Fri Apr 21 18:48:28 UTC 2023, message: Message sending failed] (InMemoryNotifier.java [taskScheduler-16])
Apr 21 18:48:28 hmis tomcat9[52774]: * INFO 2023-04-21 18:48:28,300 ‘system-process’ create org.hisp.dhis.sms.outbound.OutboundSms (AuditLogUtil.java [taskScheduler-16])

Dears,
After working on the SMS gateway again we are now receiving this error shown below when sending an SMS. Please why are we having Job ‘processingSendSmsAction’ failed, uid: GPXriMXYcES (AuditLogUtil.java [taskScheduler-4])?

Error
**Apr 23 04:57:43 hmis tomcat9[55150]: * INFO  2023-04-23 04:57:43,197 Scheduler initiated execution of job: GNtNnwXeSZd, processingSendSmsAction, SMS_SEND, null (DefaultSchedulingManager.java [tomcat-http-7])**
**Apr 23 04:57:43 hmis tomcat9[55150]: * INFO  2023-04-23 04:57:43,198 [Level: INFO, category: SMS_SEND, time: Sun Apr 23 04:57:43 UTC 2023, message: Sending SMS] (InMemoryNotifier.java [taskScheduler-4])**
**Apr 23 04:57:43 hmis tomcat9[55150]: * INFO  2023-04-23 04:57:43,201 Sending SMS to [23276710495] (SmsMessageSender.java [taskScheduler-4])**
**Apr 23 04:57:43 hmis tomcat9[55150]: * INFO  2023-04-23 04:57:43,210 'system-process' create org.hisp.dhis.message.MessageConversation, name: Job 'processingSendSmsAction' failed, uid: GPXriMXYcES (AuditLogUtil.java [taskScheduler-4])**
**Apr 23 04:57:43 hmis tomcat9[55150]: * INFO  2023-04-23 04:57:43,286 no recipient (SmsMessageSender.java [taskScheduler-9])**
**Apr 23 04:57:43 hmis tomcat9[55150]: * ERROR 2023-04-23 04:57:43,312 Job 'processingSendSmsAction' failed (DefaultJobInstance.java [taskScheduler-4])**
**Apr 23 04:57:43 hmis tomcat9[55150]: java.lang.NullPointerException**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.HashMap.merge(HashMap.java:1226)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.sms.config.SimplisticHttpGetGateWay.getUrlParameters(SimplisticHttpGetGateWay.java:160)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.sms.config.SimplisticHttpGetGateWay.buildUrl(SimplisticHttpGetGateWay.java:149)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.sms.config.SimplisticHttpGetGateWay.send(SimplisticHttpGetGateWay.java:113)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.sms.config.SmsMessageSender.sendMessage(SmsMessageSender.java:223)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.sms.config.SmsMessageSender.sendMessage(SmsMessageSender.java:151)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.lang.reflect.Method.invoke(Method.java:498)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at com.sun.proxy.$Proxy169.sendMessage(Unknown Source)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.sms.job.SendSmsJob.execute(SendSmsJob.java:80)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.scheduling.DefaultJobInstance.executeJob(DefaultJobInstance.java:155)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.scheduling.DefaultJobInstance.execute(DefaultJobInstance.java:69)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.hisp.dhis.scheduling.DefaultSchedulingManager.lambda$internalExecuteJobConfiguration$3(DefaultSchedulingManager.java:280)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.FutureTask.run(FutureTask.java:266)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.FutureTask.run(FutureTask.java:266)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)**
**Apr 23 04:57:43 hmis tomcat9[55150]:         at java.lang.Thread.run(Thread.java:750)**

@Gerald_Thomas
This is the response you are receiving from the gateway API.
Can you try using some other tool for example postman to send SMS? if that works then we need to check DHIS2 configurations.

1 Like

the last part shows a failure of the scheduler job which probably because SMS sending was failed.

1 Like

Dear Zubair,
Messages are submitted to DHIS2 but DHIS2 failed to process them. It seems like a caching problem; I deleted the configuration, recreated the setup again, and restart the server; SMS has started processing again. The outgoing messages are still not going and it is giving the error below on the Gateway server:
{
** “message”: {**
** “content”: “A suspected case of Animal Bite - Dog was detected by Petifu Junction CHC on 2023-04-30. Please call Alhaji Sorie Kamara on 23288914052 for further details”,**
** “to_number”: “23276799802,23276150605,23278647620,23279202873,23277512575,23278515606,23278419088,23279043186,23279020164,23276059534,23278964160,23276905885,23276643383,23276740799,23278674345”,**
** “provider”: “rapidpro”,**
** “reqid”: “101ee46b-7363-4ddf-800e-f19f4b7c697a”,**
** “recipients”: [**
** “23276799802”,**
** “23276150605”,**
** “23278647620”,**
** “23279202873”,**
** “23277512575”,**
** “23278515606”,**
** “23278419088”,**
** “23279043186”,**
** “23279020164”,**
** “23276059534”,**
** “23278964160”,**
** “23276905885”,**
** “23276643383”,**
** “23276740799”,**
** “23278674345”**
** ],**
** “direction”: “outgoing”,**
** “status”: “error”,**
** “error”: {**
** “name”: “Error”,**
** “message”: “{"detail":"Invalid token"}”,**
** “code”: 422**
** }**
** },**
** “level”: “error”,**
** “label”: “sms-gateway-prod”,**
** “timestamp”: “2023-05-01T12:54:41.098Z”**
}

1 Like

response says invalid token.

1 Like

can you try sending this message using postman?

1 Like

Dear Zubair,
Let me try and see

1 Like

Dear Zubair,
From Postman, I tried using POST

> /api/25/sms/outbound

and using this on the body:
{
“message”:“Sms Text”,
“recipients”: [
“23276710495”,
“23278242760”
]
}
I am getting the error below:

I also used this: /api/25/sms/outbound?message=text&recipient=23276710495 and I am getting the error below:

Zubair,
On the DHIS2 sent messages, status is failed and on the gateway, it is showing the token error:

{
“message”: {
“content”: “text”,
“to_number”: “23276710495”,
“provider”: “rapidpro”,
“reqid”: “dbf1c9e3-1e71-4aba-a76f-403ea7f3f678”,
“recipients”: [
“23276710495”
],
“direction”: “outgoing”,
“status”: “error”,
“error”: {
“name”: “Error”,
“message”: “{"detail":"Invalid token"}”,
“code”: 422
}
},
“level”: “error”,
“label”: “sms-gateway-prod”,
“timestamp”: “2023-05-01T15:34:26.786Z”
}

Zubair,
On the tomcat log it is showing this error:

May 01 15:49:50 hmis tomcat9[72395]: * INFO 2023-05-01 15:49:50,736 Sending SMS to [23276710495] (SmsMessageSender.java [tomcat-http-81])
May 01 15:49:50 hmis tomcat9[72395]: * ERROR 2023-05-01 15:49:50,787 Client error 422 Unprocessable Entity (SimplisticHttpGetGateWay.java [tomcat-http-81])
May 01 15:49:50 hmis tomcat9[72395]: * ERROR 2023-05-01 15:49:50,788 SMS failed, failure cause: failed (SmsMessageSender.java [tomcat-http-81])
May 01 15:49:50 hmis tomcat9[72395]: * WARN 2023-05-01 15:49:50,791 Resolved [org.hisp.dhis.dxf2.webmessage.WebMessageException] (AbstractHandlerExceptionResolver.java [tomcat-http-81])

Dear Zubair,

I am writing to inform you that we have resolved the issue with the SMS gateway by mimicking it successfully. This has allowed us to identify some of the errors more clearly. Previously, we noticed that DHIS2 SMS was using a POST request to send SMS in the 2.31.9 war file that we are currently using. However, something has changed, and it appears that DHIS2 SMS is not using a POST request to send SMS. Unfortunately, this has caused an issue with our gateway, resulting in the Client error 422 Unprocessable Entity Error.

I understand that upgrading would be the ideal solution. However, understanding the current issue will help us modify our app or improve the capture app. With this in mind, I would like to inquire about the request method used for SMS in DHIS2. Is DHIS2 currently using a GET request, POST request, or both for sending SMS?

Thank you for your assistance in this matter.