Search code examples
strongloop

strongloop loopback android sdk extending installation class


I am using the loopback android sdk example and trying to extend Installation Class in android SDK to add more attribute to the installation . But when I add add a new attribute it gives me the following error.

11-16 20:51:33.207    4339-4339/com.google.android.gcm.demo.app E/GCM Demo﹕ Cannot save Installation
org.apache.http.client.HttpResponseException: Unprocessable Entity
        at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:235)
        at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:79)
        at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:95)
        at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:57)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)

The way I am doing it is,

public class CustomInstallation extends LocalInstallation {


public static final java.lang.String DEVICE_IMEI= "imei";
private String imeiNumber;


public ProbeInstallation(Context applicationContext, RestAdapter loopbackAdapter) {
    super(applicationContext, loopbackAdapter);
}

public String getImeiNumber() {
    return imeiNumber;
}

public void setImeiNumber(String imeiNumber) {
    this.imeiNumber = imeiNumber;
}}

And in my MainActivity I am just using it as,

   final CustomInstallation installation =  new CustomInstallation(context, adapter);

Is this the way to do it or I am missing something?


Solution

  • The HTTP error 422 Unprocessable Entity is returned by LoopBack when the validation of the model instance failed. This typically happens when a required field (property) was not included in the request body.

    Please extend your question and add the LDL definition of your ProbeInstallation model.

    Also note that the current implementation of LocalInstallation does not fully support extending, since the save method uses always /installations URL and the URL cannot be configured. Of course, this can be easily improved, feel free to open a GitHub issue or perhaps even send a pull request.

    Disclaimer: I am the main developer of loopback-sdk-android