NullPointerException when testing my hosted Service

Hey guys,
Trying to run my simple hosted service called RewardsService that adds a row to a table,
Receiving this response body:
{
“code”: 0,
“message”: “java.lang.NullPointerException: exception during method invocationServiceException”
}

This is my main class:
public class RewardService implements IBackendlessService {

private static final String USER_REWARDS_TABLE_NAME = "userRewards";

private static final String COL_USER_ADVERTISING_ID = "userAdvertisingId";
private static final String COL_NUM_OF_COINS = "numOfCoins";
private static final String COL_EVENT_ID = "eventId";
private static final String COL_REWARD_DATE = "rewardDate";
private static final String COL_AD_NETWORK_NAME = "adNetworkName";
private static final String COL_AD_PROVIDER_NAME = "adProviderName";

public void addReward(Reward reward)
{
    // Creating reward row map
    Map rewardRowMap = new HashMap();
    rewardRowMap.put(COL_USER_ADVERTISING_ID, reward.getUserAdvertisingId());
    rewardRowMap.put(COL_NUM_OF_COINS, reward.getNumOfCoins());
    rewardRowMap.put(COL_EVENT_ID, reward.getEventId());
    rewardRowMap.put(COL_REWARD_DATE, reward.getRewardDate());
    rewardRowMap.put(COL_AD_NETWORK_NAME, reward.getAdNetworkName());
    rewardRowMap.put(COL_AD_PROVIDER_NAME, reward.getAdProviderName());

    // Saving the reward row to the DB
    Backendless.Persistence.of(USER_REWARDS_TABLE_NAME).save(rewardRowMap);
}

}also I could not understand if I’m supposed to add the row using Backendless.Persistence, Backendless.Data or Backendless.Cache.

Thanks,Tal

Hi Tal,

There is no difference between Backendless.Persistence and Backendless.Data. The latter was added for brevity in the code. Backendless.Cache is used for the API documented here:
https://backendless.com/documentation/utilities/android/ut_caching_api_android.htm

To diagnose the exception you’re getting in the hosted service, use the local debugging feature. This is when you can run the service locally while having it connected to the cloud. Here’s a video overview of the feature:
https://backendless.com/local-api-service-debugging/