Insert double quote inside a payload with InfluxDB and WSO2 Stream Processor through HTTP

Insert double quote inside a payload with InfluxDB and WSO2 Stream Processor through HTTP

I am working on a stream process which can takes informations inside my MySQL database and parse them into a NoSQL database (with InfluxDB).
At this point, i am able to send a NoSQL query through a HTTP Request, but only if i want to send integer value.
The problem is when i want to send a string value, i can’t use double quotes inside my “Text” payload, because it will close my attribut.
If i use single quote around my string value, InfluxDB returns an error :
[2018-12-28_11-07-18_302] INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} – log : Event{timestamp=1545991638301, data=[{“error”:”unable to parse ‘SEQTIME value=267,x_date_create={1}’: invalid boolean”} ], isExpired=false} (Encoded)

There is my code :
@sink(type=’http-request’,
publisher.url=’http://localhost:8086/write?db=bd_sensor_values’,
method=’POST’,
headers=”‘Authorization: Basic XXXXX’,’Content-Type: application/x-www-form-urlencoded’,’cache-control: no-cache’,’Host:localhost:8086′”,
sink.id=”httpRequest_id”,
@map(type=’text’, @payload(“SEQTIME value={{id}},x_date_create={{x_date_create}}”)))
define stream httpRequest (id int, x_date_create string);

The problem is inside the @payload attribut, with x_date_create.
I tried to encode my double quotes, but it didn’t work (maybe i did it wrong ?)
Any idea ? Thank you !

Solutions/Answers:

Solution 1:

You can use the following way to add double quotes to your results

@payload(""" "SEQTIME value"="{{id}}","x_date_create"="{{x_date_create}}" """)))

Solution 2:

Use double quotes and escape quotes in the string. See example from InfluxDB tutorial:

weather,location=us-midwest temperature="too\"hot\"" 1465839830100400200

References