API Integration HTTP

br2e2 years ago

It works like this example via CURL:

curl -X 'POST' \
  'https://http.wttz.com/394014db920b713a/rest/envio/VFYCSIA-5QNUP4I-UOCOMEQ-CC7TVXY/texto' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "messageData": {
    "numero": "5549991414646",
    "text": "Test Now"
  }
}'

Request URL

https://http.wttz.com/394014db920b713a/rest/envio/VFYCSIA-5QNUP4I-UOCOMEQ-CC7TVXY/texto

Response headers

 access-control-allow-origin: * 
 connection: keep-alive 
 content-length: 306 
 content-type: application/json; charset=utf-8 
 date: Thu,25 May 2023 05:24:38 GMT 
 etag: W/"132-7imkh414LcySqxrh9Vx3hTPcX70" 
 server: nginx/1.18.0 (Ubuntu) 
 vary: X-HTTP-Method-Override,Accept-Encoding 
 x-request-id: 7db4bec141344be59324fe7cad1e3585 

this api accepts post in json format
I am using provider sms NotificatorSms me to integrate traccar?

        <entry key='sms.http.url'>org.traccar.sms.HttpSmsClient</entry>
        <entry key='sms.http.url'>https://http.wttz.com/394014db920b713a/rest/envio/VFYCSIA-5QNUP4I-UOCOMEQ-CC7TVXY/texto</entry>
        <entry key='sms.http.template'>
                                            {
                                              "messageData": {
                                                "numero": "{phone}",
                                                "text": "{message}"
                                              }
                                            }
        </entry>

debugging gives the second error

NullPointerException (NotificatorSms:45 < NotificationResource:63 < ...)

I'm on the right track can you help me?????

Anton Tananaev2 years ago

Are you using the latest official release of Traccar? No customizations?

br2e2 years ago

I'm using the customized 4.15 version plus the http sms api I keep it as the official one

Anton Tananaev2 years ago

You should try it on the latest official release.

br2e2 years ago

just one more question like this works but putting {message} of the error can help me and some xml conversion to json?
let me know what I really need to put there?

        <entry key='sms.http.url'>org.traccar.sms.HttpSmsClient</entry>
        <entry key='sms.http.url'>https://http.wttz.com/394014db920b713a/rest/envio/VFYCSIA-5QNUP4I-UOCOMEQ-CC7TVXY/texto</entry>
        <entry key='sms.http.template'>
                                            {
                                              "messageData": {
                                                "numero": {phone},
                                                "text": <b>"Test" <--- PASSING A STRING WORKS PASSING {message} the template breaks 
                                              }
                                            }
        </entry>