Introduction to Kinvey-Flash integration

Kinvey is new next-level Backend as a Service (BaaS) platform of choice for the wikiBudgets project. Kinvey aims to support "any platform" and even though they do not list Flash/AS3 explicitly in their documentation when I contacted them about this option they were excited (same as me) and promised their full support. And they delivered it.

Kinvey offers pretty comprehensive REST API - a good start point for every AS3 app. The problem however lies on the side of Flash Player. For various (security?) reasons Flash limits the use of request submission methods as well as request headers. The problems can be divided into three categories:
  • Flash does not support request methods other than GET or POST. Forget PUT, POST, DELETE or others. (There are various workarounds but they always depend on the server)
  • On top of this there is a strange limitation on the POST request. It must contain non-empty payload (body) else it falls back to the GET method. 
  • The third limitation is on the side of HTTP headers (aka URLRequestHeader). The AS3 documentation humbly reveals that custom headers are only supported for POST request method, not GET.
Kinvey team came up with an elegant turnkey solution: In your Flash app always use the POST method for the request and submit the desired request method (as specified by the documentation) in the request payload object in a "_httpmethod" variable.

Please enjoy this complete example of the Handshake request:

1 comment:

  1. check out this FlexSDK / Kinvey integration library.