Google App Engine Java/Scala servlet not receiving Angular 2 Http post data

0 views
Skip to first unread message

Tim Consolazio

unread,
Jan 19, 2017, 8:31:48 AM1/19/17
to Angular 2
If you're using Angular 2 (and probably the same is true in Angular 1.x but I don't know for sure, I don't use 1.x anymore), and trying to send an HTTP post to a Java servlet on the Google Application Engine. It may not be working. 

The problem is that Angular 2 defaults it's http post headers to "application/json", so you just send your JS object without any manipulation and that's that. 

But as-is, a Java servlet doesn't understand that. The fix is to stringify your JSON data, and change the header to "application/x-www-form-urlencoded"

Article and code samples here:

www.tcoz.com/#/errata
Reply all
Reply to author
Forward
0 new messages