StorageServices and Error Codes "1400" and "400"

0 votes

Im using Unity3D engine along with StorageServices. But encountering following error on execution...

Exception : com.shephertz.app42.paas.sdk.csharp.App42BadParameterException: {"httpErrorCode":400, "appErrorCode":1400, "message":"Bad Request", "details":"The Request parameters are invalid"}
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
UnityCallBack:OnException(Exception) (at Assets/UnityCallBack.cs:23)
com.shephertz.app42.paas.sdk.csharp.connection.<execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
 
 
Scripts:
 
using UnityEngine;
using System.Collections;
using com.shephertz.app42.paas.sdk.csharp;
using com.shephertz.app42.paas.sdk.csharp.storage;
using System.Collections.Generic;
using System;
 
public class test :MonoBehaviour{
 
StorageService storageService;
// Use this for initialization
void Start () {
 
App42API.Initialize("API key","secret key"); 
storageService = App42API.BuildStorageService();
 
 
string dbName = "Test";
string collectionName = "Test_Collection"; 
string json = "Test!!";
App42Log.SetDebug(true); //Print output in your editor console
 
storageService.InsertJSONDocument(dbName, collectionName, json, new UnityCallBack()); 
 
}
}

 

public class UnityCallBack : App42CallBack
{
public void OnSuccess(object response)
{
Storage storage = (Storage) response;
IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList(); 
for(int i=0;i <jsonDocList.Count;i++)
{   
App42Log.Console("objectId is " + jsonDocList[i].GetDocId());
}  
}
 
public void OnException(Exception e)
{
App42Log.Console("Exception : " + e);
}
}
 
Any solution?
asked Nov 14, 2014 in App42 Cloud API-BaaS by 0bytedna (10 points)
edited Nov 14, 2014 by 0bytedna

1 Answer

0 votes

Hello Obytedna,

Thanks for sharing the code snippet with us. 

Kindly put the valid JSON format in the method call as the value you are passing is not the valid one. Kindly use the below one.

String json = "Test!!";

to 

String json = "{\"test\":\"InsertJSONDocument\",\"data\":\"inserted in App42 data base\"}";

it will resole your issue. Let us know if it helps.

Thanks

Himanshu Sharma

answered Nov 16, 2014 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...