1

We are using RTI webhook to post the message notification to store it in Cloudant DB. We are passing {{message}} parameter to the POST call body. Upon storage we notice the "/" character before every quote("). This seems to be a bug as this make the JSON invalid to consume at later stage. Below is the example of what {{message}} contains in one of our case

"{\"d\":{\"Energy_Consumption\":150,\"pressure\":36.84546626947179,\"water_usage\":1640.0274074248778,\"temp\":45},\"ts\":\"2016-03-15T06:48:02.320+0000\",\"ruleContent\":{\"id\":\"J4jn6Wqv\",\"contextSchemas\":[],\"ruleCondition\":\"IOT_DeviceSchema.d.temp>40 AND IOT_DeviceSchema.d.pressure<80 AND IOT_DeviceSchema.d.Energy_Consumption>100\",\"messageSchemas\":[\"IOT_DeviceSchema\"],\"jobID\":\"tOXtlQLA\",\"name\":\"Device_Alert\",\"severity\":2,\"actions\":[\"Xfy2CCx6\"],\"transforms\":[],\"destination\":\"tenant.228e9515-9a62-448a-ba9a-a570000ba619.ruleOutput\"},\"deviceId\":\"ftkgac:IOTsample_devicetype:Device03\"}"

Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
Manoj K Sardana
  • 153
  • 1
  • 4
  • 14

1 Answers1

0

{{message}} is embed in webhook json body, that is why it is encoded.

if webhook server itself is a java program or others can parse json from a string, there is no issue. IFTTT, Node-red, requestbin, Maximo web server are examples where the parsing happens correctly.

In this case, webhook is being used to call cloudant API to save the webhook body as cloudant document directly. The escaped string is saved to cloudant db directly without any parsing.

Another option would be to run this thru a parser before saving to cloudant.

We will investigate further to see what we can do on the RTI side.

can I ask what you want to do in "later stage" after you save it in cloudant? When you get this thru java/js, the message can be parsed to correct json body.

serenabi
  • 1
  • 2
  • you said "Another option would be to run this thru a parser before saving to cloudant" I dont think this option is feasible. The only interface RTI provide to integrate is webhook. I have to call the API, be it cloudant or my own. If you mean I should write a API just to parse the message before sending it to cloudant, I see it defeating the purpose of quick implementation of any application. RTI should be able to send right JSON to the POST API irrespective of the consumer. – Manoj K Sardana Mar 18 '16 at 11:22
  • Anyway my consumer to the cloudant data is an SPSS model been deployed on predictive analytics services. This service is an interface to a web application which predicts some events based on the model. – Manoj K Sardana Mar 18 '16 at 11:23
  • can you try when SPSS module get the data from cloudant, it can get correct Json object? we hope this will not block you. in the meanwhile we are working a solution for your case. – serenabi Mar 21 '16 at 11:39
  • SPSS modeler does not have cloudant as data source available yet. We are using a utility which help us put the cloudant in report-Ops section. This run an R script to fetch all the documents and convert it to a Relational model. This seems to be working as I dont see "\" in the converted relational model by this utility. – Manoj K Sardana Mar 22 '16 at 07:17