As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Performing a POST request to Kinvey over "GAE Business" with parameters
I
Ismail Issa
started a topic
over 9 years ago
Hello,
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 ?!
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 `appdata.save` 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:
@Key
private String operation;
@Key
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.
I
Ismail Issa
said
over 9 years ago
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 ?!
Thanks
E
Edward
said
over 9 years ago
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.
Ismail Issa
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 ?!
Thanks,