Julyan
October 25, 2023, 11:00am
1
Hi,
When I choose SEND_DATA_AS_JSON “yes” while creating SMS Gateway:
Config - SMS Gateways - Create new SMS Gateway definition - ProviderModule “HttpSMSProvider” - SEND_DATA_AS_JSON “yes”
I whould like to add the following json which has included additional level with “body” item. Is it possible to do? I can’t find how to do it.
json data:
{
“chat_id”: “id”,
“notification”: {
“body”: “text”
}
}
thanks
Julyan
September 16, 2024, 12:33pm
2
Hello
Any plans to add support for nested JSON in future versions?
opened 04:59PM - 18 Jan 23 UTC
Type: Enhancement
Prio: Medium
<!--
Thank you for filing a bug within privacyIDEA. The more information you pr… ovide, the easier it is to identify the problem!
Issues are not meant for asking questions! You're welcome to ask questions in our community forum: https://community.privacyidea.org
privacyIDEA is licensed under the AGPL and comes without warranty. If you require reliable, professional help, please consider getting either
- consultancy
(https://netknights.it/en/leistungen/one-time-services/)
- or the privacyIDEA Enterprise Edition
(https://netknights.it/en/leistungen/service-level-agreements/)
-->
### Top-level intent
What did you try to achieve?
Configure the SMS gateway for our SMS service provider:
* https://docs.spryngsms.com/#intro
For this I am using the HTTP provider setup. But one of the required fields `recipients` is a JSON list. Think more SMS providers have this
### Steps to reproduce
1. Configure the SMS gateway with the required paramters
### Expected outcome
I should receive a SMS OTP code
### Actual outcome
Got an HTTP errcode: 422
### Configuration
* **privacyIDEA version**: 3.8.0
* **Installation method**: (from Ubuntu packages, github, PyPI, ...) : pipenv
* **Python version**: 3.7.3
* **Operating system**:: debian 10
* **Webserver**: apache 2.4
* **Token database**: (MySQL, PostgreSQL, ...): MySQL
### Log file
**Set PI_LOGLEVEL = logging.DEBUG in pi.cfg and take a look at the privacyidea.log!**
**If appropriate, attach the log file or paste relevant portions.**
I have this patch applied and it works as expected but is not very portable:
* lib/smsprovider/HttpSMSProvider.py
```
log.debug("HvB")
for k, v in self.smsgateway.option_dict.items():
if k not in self.parameters().get("parameters"):
# This is an additional option
log.debug(f"HvB: {k}:{v}")
if k in [ 'recipients' ]:
value = v.format(otp=message, phone=phone)
parameter[k] = list()
parameter[k].append(value)
else:
value = v.format(otp=message, phone=phone)
parameter[k] = v.format(otp=message, phone=phone)
log.debug(f"HvB formated : {k}:{value}")
```
Maybe add some logic to the webinterface if attribute is a list object
Take a look at the issue and its assigned milestone.