Parsing FORM-ENCODED Parameters Using GRAILS (Charging Webcams)

I have a GRAILS 3 controller that receives an HTTP message from webservice ( Chargify ) with this format (the payload section contains about 100 entries with a large number of subfields):

 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 it possible with GRAILS to analyze part of the "payload" and dynamically convert it to a POJO (or a simple hash file) ? Chargify use this strange format not recognized by the GRAILS framework , and I cannot analyze it automatically.

Is there anyone who can help me figure it out? Thank you for your help.

+5
source share
2 answers

Can you try this?

 def readChargify() { String requestData = request.reader.text def reqMap = org.grails.web.util.WebUtils.fromQueryString(requestData) } 
0
source

This Java library for parsing the body of webhooks was contributed by another Chargify client and may be useful:

https://github.com/prowave/chargify-webhook-java

0
source

Source: https://habr.com/ru/post/1245992/


All Articles