Start a new topic

Performing a POST request to Kinvey over "GAE Business" with parameters


I made a business logic layer over GAE, and I'm able to interact with it using the "API Console" by choosing the POST method and sending a JSON-like parameters in the request.

My question is how to do so from my android client, to interact with the same way ?!


If your business logic is set up as a on pre-save collection hook, you can perform any save operation to trigger this:

`myClient.appData("myCollection", MyEntity.class).save(myEntity, new KinveyClientCallback(){ ... });`

This will upload the `myEntity` object, and will trigger that POST business logic.
Hi Edward,

Actually what I have is a custom business logic hosted on Google App Engine, and what I'm doing from the API Console Simulator right now is like follows:

1) Choose POST method for a certain collection

2) In the Request body I put a JSON-like parameters (ex. {'operation':'filter','output':'allData'})

3) In my custom BL code I parse the parameters and according to them I return the appropriate output

The previous is working perfectly from the API Console, the question is how to do so from inside android sdk ?!

Hey, just to confirm-- Are you using a `Collection Hook` or a `Custom Endpoint`?

If it's a `Collection Hook`, and then you can use `` method mentioned earlier:

Create a new class that `extends GenericJson`, and call it whatever you want-- for this example I will the class `MyEntity`.

Within this class, define:


private String operation;


private String output;

etc. Make sure this class has a constructor with no arguments: `public MyEntity(){}`

The combination of extending `GenericJson` and the `@Key` annotation for all your fields will allow us to marshall it into a JSON string. When you call save, pass an instance of this object and it will perform a POST (or PUT) operation, which will trigger your Collection Hook.

If you are using a Custom Endpoint, there is a `myClient.customEndpoints(MyResponse.class)`, which will allow you to hit Endpoints specifying both the Input and Output classes as GenericJson.
Login or Signup to post a comment