Search code examples
jsonstoreibm-mobilefirst

JSONStore push() gives "Data conversion error"


I am using MobileFirst Platform 6.3.0.00-20141218-1823.

Using the following JSONStore push code snippet returns an error:

Procedure invocation error. Runtime: Data conversion error converting "{""FIRSTNAME"":""abcd"",""CONTACTNO"":9090909099,""ID"":2,""EMAIL"":""abcd@gmail.com"",""LASTNAME"":""xyz""}"; SQL statement:
delete from addressbook where id=? [22018-184].
Performed query:
delete from addressbook where id=?

The code:

WL.JSONStore.get(collectionName).countAllDirty().then(function(numberOfDirtyDocs){
    if(numberOfDirtyDocs > 0){
        WL.JSONStore.get(collectionName).push().then(function(){
            deferred.resolve(true);
        }).fail(function(errorObject){
            deferred.reject(false);
        });
        deferred.resolve(numberOfDirtyDocs);
    }else{
        deferred.reject(numberOfDirtyDocs);
    }
}).fail(function(errorObject){
    deferred.reject(errorObject);
})

How do I debug this to find a solution?


Solution

  • I found the problem was in my adapter code. I had to

    JSON.parse(input object)
    

    in my adapter code. Also I needed to use uppercase for the keys in the json object.