Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am trying to set up a job trigerred by a webhook, and I am having trouble parsing the body of the request I'm sending to the job.
The body I am sending to the job looks like this :
And my resource_webhook_payload variable look like this :
tLogRow_2 - Content of row 1: [{"data":"{"testKey1" : "test1" ,"testKey2" : "test2"}","type":"application/json"}]
We can see that there are now double-quotes surrounding the json body. I am then trying to parse each json keys, but I am failing to do so because of these double-quotes : when using tExtractJsonFields, I am getting the error
tExtractJSONFields_1 - Cannot determine next state.
When I escape the double-quotes in my request by using "\", I am able to parse the body properly :
However, I would like to be able to parse the request without having to escape every double-quotes in the request body.
Does anyone know the proper way to parse the
resource_webhook_payload variable ?
Thank you !
Hi
It is an invalid json format for tExtractJsonFields component parsing, try to add escape char "\" to the string before tExtractJsonFields in the job. eg:
....tJavaRow--main--tExtractJsonFields
on tJavaRow:
output_row.columnName=input_row.columnName.replace("\"testKey1\"","\\\"testKey1\\\"").replace("\"testKey2\"","\\\"testKey2\\\"");
Regards
Shong
Hello,
Thank you for your reply.
However, do you know if there is another way to parse the resource_webhook_payload without having to manually escape the double-quotes ?
The json body I am sending initially is properly formated, for example :
{
"testKey1": "testValue1",
"testKey2": "testValue2"
}
So I would like to be able to use this directly, without having to manually remove the double-quotes.
Thank you,
If you don't escape or remove the double-quotes, it is in invalid json string, tExtractJsonField can't parse it. I'm afraid what you can do is to remove the double-quotes if there are double-quotes surrounding the json body in the job.
Hello,
I'm quite interested in the webhook solution to trigger some jobs.
Though, I could not understand from the documentation how I should implement the job to read from the resource_webhook_payload. How should a job look like for such implementation ? What component should I use to read from the webhook ?