Reputation: 340
I have a GRAILS 3 controller that receive an HTTP post from a webservice (Chargify
) with this format (the payload section has about 100 entries with a lot of sub-fields):
POST / HTTP/1.1
Accept: */*; q=0.5, application/xml
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
X-Chargify-Webhook-Id: 81309408
X-Chargify-Webhook-Signature: xxxxxxxxxxxxx
X-Chargify-Webhook-Signature-Hmac-Sha-256: yyyyyyyyyyyyyy
Content-Length: 48
User-Agent: Ruby
X-Newrelic-Id: xxxxxx
X-Newrelic-Transaction: aaaaaaaaaaaaaa=
Host: myhost.test.it
id=81197881&event=statement_settled&payload[site][id]=12345&payload[site][subdomain]=test-sandbox
Is there any way with GRAILS to parse the "payload" part and convert it dynamically to a POJO (or also a simple hashmap)?. Chargify
use this strange format not recognized by GRAILS framework
and I'm unable to parse it automatically.
Is there anyone to help me for parsing? Advance thanks for helping.
Upvotes: 5
Views: 352
Reputation: 168
This Java library to parse the body of webhooks was contributed by another Chargify customer and may be helpful:
https://github.com/prowave/chargify-webhook-java
Upvotes: 0
Reputation: 1441
Can you try this ?
def readChargify() {
String requestData = request.reader.text
def reqMap = org.grails.web.util.WebUtils.fromQueryString(requestData)
}
Upvotes: 0