kalkun-sms/Kalkun

REST_API - Missing or invalid default region

Closed this issue · 4 comments

Hello!
Sending SMS via REST_API works fine if you log in directly to kalkun before that. But, if this is not done, the request leads to an error.

An uncaught Exception was encountered

Type: libphonenumber\NumberParseException

Message: Missing or invalid default region.

Filename: /var/www/vendor/giggsey/libphonenumber-for-php/src/PhoneNumberUtil.php

Line Number: 1659

Backtrace:

File: /var/www/vendor/giggsey/libphonenumber-for-php/src/PhoneNumberUtil.php
Line: 3108
Function: parseHelper

File: /var/www/application/helpers/kalkun_helper.php
Line: 371
Function: parse

File: /var/www/application/models/gateway/Gammu_model.php
Line: 192
Function: phone_format_e164

File: /var/www/application/models/gateway/Gammu_model.php
Line: 163
Function: _send_message_route

File: /var/www/application/models/Message_model.php
Line: 42
Function: send_messages

File: /var/www/application/plugins/rest_api/controllers/Rest_api.php
Line: 49
Function: __call

File: /var/www/application/plugins/rest_api/libraries/REST_Controller.php
Line: 182
Function: send_sms_get

File: /var/www/index.php
Line: 315
Function: require_once

  • Kalkun version: 0.8.0-beta-4-dev [Lang: russian] [CountryCode: RU]
  • Operating system: Linux 3299b6bfe081 5.15.0-43-generic #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 x86_64
  • PHP Version: 8.0.22
  • DB Backend: MySQLi 10.6.5-MariaDB-1:10.6.5+maria~focal (mysqli)
  • Gammu version: Gammu 1.42.0, Linux, kernel 5.15.0-43-generic (#46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022), GCC 11.2
  • Gammu DB schema: 17
  • Browser: Chrome 104.0.0.0
  • Plugins: rest_api

What is the exact URL you use (with parameters) for the REST call?

You must use a phone number in international format when using REST api. Since the Region set in the settings is user dependent, and since indeed you cannot be logged in when using REST, the phone number must be in international format (leading + with country code, like +111111111). Maybe that's the problem.

// Default value to '' for the case this is called through Daemon or API

// This way, we consider number is already in international format.

Yes, I know, and I use the number in the international format.
image

By the way, if I log in to kalkun before using REST_API, then in the xml response I see a number not in international format.
image

I updated the wiki https://github.com/kalkun-sms/Kalkun/wiki/Plugin:-REST-Api
Please follow it again and tell me if that fixes your issues.

Thank you for the tip. The issue was fixed.