1

I'm trying to use Orion notification to send SMS with Plivo. This is how I send an SMS directly with Plivo:

curl -X POST https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1/Message/ -L -u MAMDA5ZDJIM:YzhiNDJjODNhNDkxMjhiYTgxZD -H 'Content-Type: application/json' -d @- <<EOF
{
   "src": "0039414141414",
   "dst": "0039414747111",
   "text": "test SMS"
}
EOF

How should I encode it in Orion? I tried:

curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json'  -d @- <<EOF
{
  "description": "A subscription to get info about WS_UPPA_Sensor2",
  "subject": {
    "entities": [
      {
        "id": "Sensor1",
        "type": "SensingDevice"
      }
    ],
    "condition": {
      "attrs": [
        "temperature"
      ]
    }
  },
  "notification": {
    "httpCustom": {
      "url": "https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1NZVMZD/Message/",
      "headers": {
         "Authorization": "Basic TUFNREE1WkRKSU1ETTFOWlZNWkQ6WXpoaU5ESmpPRE5oTkRreE1qaGlZVGd4WkRkaE5qYzNPV1ZsTnpZMA=="
      },
      "payload": "{%22src%22%3A%2200393806412092%22%2C%22dst%22%3A%2200393806412093%22%2C%22text%22%3A%22test%20SMS%20from%20Waziup%22}"

    },
    "attrs": [
      "temperature"
    ]
  },
  "expires": "2040-01-01T14:00:00.00Z",
  "throttling": 5
}
EOF

Is there another way than percent encoding?

cdupont
  • 1,138
  • 10
  • 17

1 Answers1

0

URL encoding (I understand is the one you refer by "percent encoding") is the only one which have an special treatment in custom notifications (details described as part of the Orion documentation).

In fact, taking into account the existing one is complete (I mean, any text can be expressed in the terms of URL encoding) there is no need of adding any other.

fgalan
  • 11,732
  • 9
  • 46
  • 89
  • As seen in http://fiware-orion.readthedocs.io/en/master/user/forbidden_characters/#specific-restrictions-for-id-fields I encoded my payload like that: "payload": "{ %22src%22: %2200393806412092%22, %22dst%22: %2200393806412093%22, %22text%22: %22test%22}" Is it correct? Only the quotes need to be escaped (not "}" or ":" or ",") ? – cdupont May 19 '17 at 09:51
  • That's correct. "}", ":" and "," are not forbiden chars so they can be use directly. I'd suggest to check what is Orion actually sending, e.g. using the http://requestb.in tool (adjusting subscription `"url"` accordingly, of course). – fgalan May 19 '17 at 17:15