0

I need to check backend with POST JSON but cannot find a way to do this. Below is the curl POST that works. How do I do with in HAPROXY httpchk

 curl -H "Content-Type: application/json" -X POST -d '["za.co.calculator",{"grossMonthlyIncome":["java.math.BigDecimal",100000.00],"loanTermYears":20,"interestRate":["java.math.BigDecimal",10.25]}]' https://servername/calculator/api/calculator/calculateMaximumLoanAmount 

My HaProxy config is:

option httpchk POST /calculator-service-2.0/api/calculator/calculateMaximumLoanAmount HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 174\r\n\r\n{"za.co.fnb.soa.calculator.dto.S_MaxBondInputInfo",{"grossMonthlyIncome":["java.math.BigDecimal",100000.00],"loanTermYears":20,"interestRate":["java.math.BigDecimal",10.25]}}
isa
  • 1
  • 1
  • 2

2 Answers2

1

Would be nice if you would have shown what you've tried before you came here asking for help, but anyway..I didn't test the following, but this might serve you as a starting point:

option httpchk POST /calculator/api/calculator/calculateMaximumLoanAmount HTTP/1.1\r\nContent-Type:\ application/json\r\nContent-Length:\ 144\r\n\r\n["za.co.calculator",{"grossMonthlyIncome":["java.math.BigDecimal",100000.00],"loanTermYears":20,"interestRate":["java.math.BigDecimal",10.25]}]

Note: You might need to fix the Content-Lengtt param and escaping of special chars, newlines, etc.

gxx
  • 5,591
  • 2
  • 22
  • 42
  • You beat me by 40 seconds. I think the content-length needs to be 144 for this request (that's the length of the original request anyway) – Mark Henderson Oct 11 '17 at 11:02
  • @MarkHenderson ;) Thanks, I'll incorporate your fix. – gxx Oct 11 '17 at 11:02
  • I have added my config above. The reason I had 174 was when I ran curl with -v it shows at content lenght 174 – isa Oct 12 '17 at 06:19
  • @gf_ I tried you config, which doesnt work. – isa Oct 12 '17 at 06:48
  • @isa "Doesn't work" isn't really helpful. Please elaborate, show your full config, omit sensitive details if needed, and / or logs showing the failing health check. – gxx Oct 12 '17 at 08:54
0

Hi I finally have it working. I needed to add the Host:\ haproxyservices

option httpchk POST /calculator/api/calculator/calculateMaximumLoanAmount HTTP/1.1\r\nHost:\ haproxyservices\r\nContent-Type: application/json\r\nContent-Length:\ 174\r\n\r\n{"za.co.calculator",{"grossMonthlyIncome":["java.math.BigDecimal",100000.00],"loanTermYears":20,"interestRate":["java.math.BigDecimal",10.25]}}

Thanks for the assistance.

isa
  • 1
  • 1
  • 2