Check Rate Error

266 views
Skip to first unread message

Zemen Admin

unread,
Feb 13, 2018, 5:04:38 AM2/13/18
to Jasmin SMS Gateway
Hi everyone,

I am getting a 412 Precondition failed problem trying to do a rate check. I am sending a request like this to http://127.0.0.1:8080/secure/rate?to=0911202328. The payload is as follows: 

{

  "headers" : {

    "Accept" : [ "application/json" ],

    "Content-Type" : [ "application/json" ],

    "Authorization" : [ "Basic Z2FkbW34nRlc3Q=" ]

  },

  "body" : null

}


I am getting a  HttpClientErrorException: 412 Precondition Failed

My ping and balance check GET requests work find. Here is an example of a Balance Request to http://127.0.0.1:8080/secure/balance

{

  "headers" : {

    "Accept" : [ "application/json" ],

    "Content-Type" : [ "application/json" ],

    "Authorization" : [ "Basic Z4742343lc3Q=" ]

  },

  "body" : null

}


A CURL request for Check Rate fails from the command line but with a different unparsable error.

curl -X GET -H 'Authorization: Basic Z28475621nRlc3Q=' http://127.0.0.1:8080/secure/rate?to=19012233451


{"title": "Cannot parse JSON data", "description": "Got unparseable json data: "}


Here is my router printout

jcli : mtrouter -l 

#Order Type                    Rate       Connector ID(s)                                  Filter(s)                                                       

#0     DefaultRoute            0.10000    smppc(SMPP_SRV)                                                                                            

Total MT Routes: 1

jcli : mtrouter -s 0

DefaultRoute to smppc(SMPP_SRV) rated 0.10


Thank you for the help.

Yonatan,

Zemen Admin

unread,
Feb 15, 2018, 11:06:12 AM2/15/18
to Jasmin SMS Gateway
Hi Bruno,

Any help? Much appreciated. 

Yonatan,

Bruno C

unread,
Feb 17, 2018, 4:10:54 AM2/17/18
to Jasmin SMS Gateway
Hello there !

You are invoking the rest api wich is actually a wrapper on top of the http api, try invoking the http api directly, do you get the same error ?

Moreover, the rate method is just like the send, with message sending disabled, so maybe you need to provide all the mandatory options, including the text content as well ...

Please update on this ...

Zemen Admin

unread,
Feb 19, 2018, 9:56:08 AM2/19/18
to Jasmin SMS Gateway
Hi Bruno,

Thanks again for your help.  Here is an update. 

The underlying HTTP rate-check works fine.  Here are the tests I run.

First, just test it by throwing-in a rate check without any parameters

"Mandatory argument [username] is not found."

This is expected.  Now, let's send in everything but the ‘to’ parameter. This is the only mandatory parameter per the documentation (in addition to username and password): http://jasmin.readthedocs.io/en/latest/apis/ja-http/index.html#checking-account-balance 

"Mandatory argument [to] is not found.”

Again, this is expected.  Now, provide all necessary parameters.

{"submit_sm_count": 1, "unit_rate": 0.1}

So, the HTTP rate-check works. Now, let’s use the REST API and send in a rate check request. The expected behavior for the following params is authorization failure (because I am passing in wrong credentials).  Command is  copied straight from the example here: http://jasmin.readthedocs.io/en/latest/apis/rest/index.html#restapi-get-rate

curl -X GET -H 'Authorization: Basic Zm9vOmJhcg==' http://127.0.0.1:8080/secure/rate?to=19012233451
{"title": "Cannot parse JSON data", "description": "Got unparseable json data: “}

So, the above error should NOT happen.  Per the docs(both for HTTP and REST APIs), the only mandatory parameters are username, password, and 'to'. 

But still, let's try the REST API again but provide all parameters, mandatory or otherwise. This is a false test because the underlying HTTP API works with just the mandatory parameters - so this can’t be the reason for the REST API failure.

curl -X GET -H 'Authorization: Basic Zm9vOmJhcg==' "http://127.0.0.1:8080/secure/rate?to=19012233451&from=jascli&content=thisdata"
{"title": "Cannot parse JSON data", "description": "Got unparseable json data: "}

Maybe, let's just provide EVERYTHING including coding

{"title": "Cannot parse JSON data", "description": "Got unparseable json data: "}

I am stumped at this point.  

Thank you Bruno.

Yonatan, 

Zemen Admin

unread,
Feb 27, 2018, 5:38:57 AM2/27/18
to Jasmin SMS Gateway
Hi Bruno,

Any updates on the below?

Thanks.

Yonatan

Bruno C

unread,
Mar 12, 2018, 5:02:07 PM3/12/18
to Jasmin SMS Gateway

Zemen Admin

unread,
Mar 14, 2018, 7:37:18 AM3/14/18
to Jasmin SMS Gateway
Hi Bruno,

Thanks for your response.  However, the problem has nothing to do with sending a single message.  It is about checking rate.  I have posted a detailed step-by-step actions I took to reproduce the problem.

I would greatly appreciate it if you can point out where I am going wrong.  I have read the documentation in detail.  

Thanks for the help as usual.

Yonatan,

Bruno C

unread,
Mar 14, 2018, 4:53:25 PM3/14/18
to Jasmin SMS Gateway

Bruno C

unread,
Mar 14, 2018, 5:04:18 PM3/14/18
to Jasmin SMS Gateway
And already fixed, it will be released under 0.9.28, meanwhile you can patch 0.9.27 yourself: https://github.com/jookies/jasmin/commit/6bf45c1c84c66bce9d5a7a0443fa65e0317fc5d2

Zemen Admin

unread,
Mar 15, 2018, 2:22:42 AM3/15/18
to Jasmin SMS Gateway
Bruno,

Awesome! Thanks.

Yonatan,

Divyesh Prajapati

unread,
Mar 29, 2019, 1:50:08 PM3/29/19
to Jasmin SMS Gateway
Hello Bruno,

I'm trying to send sms with restfull-api as bulk sms. but message not delivered on my two number. following error occur.

{"title": "Cannot parse JSON data", "description": "Got unparseable json data: {\n  \"to\": \"123456789\", \"123456789\"\n  \"from\": \"jasmin-sms\",\n  \"content\": \"Hello\",\n  \"dlr\": \"yes\",\n  \"dlr-url\": \"http://127.0.0.1/python1st.py\",\n  \"dlr-level\": 3\n}"}

and secod error is

{"data": {"batchId": "79349dbe-ad95-494f-af21-83233f994dcc", "messageCount": 0}}
(i did not get message).

i'm using curl script for sending

 is shown below.



curl -X POST -H 'Authorization: Basic Zm9vOmJhcg==' -d '{
  "messages": [
    {
      "to": [
        "33333331",
        "33333332",
        "33333333"
      ],
      "content": "Same content goes to 3 numbers"
    }
  ]
}' http://127.0.0.1:8080/secure/sendbatch

Amelye Chatila

unread,
Mar 30, 2019, 4:02:32 AM3/30/19
to Jasmin SMS Gateway
Hello Divyesh,


Try below curl request, seems issues with '\n'

curl --request POST --url 'http://127.0.0.1:8080/secure/sendbatch' --header 'authorization: Basic Zm9vOmJhcg==' --header 'content-type: application/json' --data '{"messages": [{"to": ["33333331","33333332","33333333"],"content": "Same content goes to 3 numbers"}]}'

Divyesh Prajapati

unread,
Apr 1, 2019, 5:35:25 AM4/1/19
to Jasmin SMS Gateway
How can i send bulk sms with out rest api. Abd with python script. plz suggest me.
Reply all
Reply to author
Forward
0 new messages