The Request parameters are invalid

0 votes

Hi,

I have this error when I try tu update json by query:

Exception is : com.shephertz.app42.paas.sdk.csharp.App42BadParameterException: {"httpErrorCode":"400", "appErrorCode":"1400", "message":"Bad Request", "details":"The Request parameters are invalid"}
UnityEngine.Debug:Log(Object)
RavrJsonVideoResponse:OnException(Exception) (at Assets/_RAVR_V1/Scripts/RavrJsonVideoResponse.cs:34)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:HandleException(String, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.connection.<Execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

With this function :

private void ProcessMedias(string jsonString)
    {
        jsonMedias = JsonMapper.ToObject(jsonString);

        mediaCount = jsonMedias["media"].Count;
        Debug.Log("mediaCount " + mediaCount);

        if (mediaCount >= 1)
        {
            // Loop through media
            for (int i = 0; i < mediaCount; i++)
            {
                string regVideo = Regex.Match(jsonMedias["media"][i]["video"].ToString(), @".*\/([^/]*)$").Groups[1].Value.ToString().Replace(" ", "");
                string currentVideo = Regex.Match(RavrDataManager.Instance.CurrentVideo, @".*\/([^/]*)$").Groups[1].Value.ToString().Replace(" ", "");
                // If video url is same of selected video url
                if (regVideo == currentVideo)
                {
                    // Addition old value to new value (+1)
                    int currentLike;
                    int.TryParse(jsonMedias["media"][i]["liked"].ToString(), out currentLike);
                    value = currentLike + 1;

                    Query q1 = QueryBuilder.Build("video", RavrDataManager.Instance.CurrentVideo, Operator.EQUALS); // Build query q1 for key1 equal to video and value1 equal to current video url  
                    Query q2 = QueryBuilder.Build("liked", value.ToString(), Operator.LESS_THAN); // Build query q2 for key2 equal to liked and value2 less than new value   
                    Query query = QueryBuilder.CompoundOperator(q1, Operator.AND, q2);

                    // Call storage to update value for key "liked"
                    storageService.UpdateDocumentByQuery(RavrConstant.dbName, RavrDataManager.Instance.CurrentCountryName, query, jsonString, callBackUpdate);
                    return;
                }
            }
        }
    }

What is wrong ? 

my json:

{"media":[{"id":"1","isWtfVideo":"false","title":"Child Climbs Historic Human Tower","price":"0","description":"\"null\"","liked":"5","isHotelVideo":"false","cityName":"\"null\"","image":"http://s3.amazonaws.com/ravrmedia/Spain/Child Climbs Historic Human Tower.jpg","thumb":"http://s3.amazonaws.com/ravrmedia/Spain/Child Climbs Historic Human Tower.jpg","video":"http://s3.amazonaws.com/ravrmedia/Spain/Child Climbs Historic Human Tower.mp4"},{"id":"2","isWtfVideo":"false","title":"City Guide of Barcelona","price":"0","description":"\"null\"","liked":"5","isHotelVideo":"false","cityName":"\"null\"","image":"http://s3.amazonaws.com/ravrmedia/Spain/City Guide of Barcelona.jpg","thumb":"http://s3.amazonaws.com/ravrmedia/Spain/City Guide of Barcelona.jpg","video":"http://s3.amazonaws.com/ravrmedia/Spain/City Guide of Barcelona.mp4"},{"id":"3","isWtfVideo":"false","title":"Hot Air Balloon Flight Spain","price":"0","description":"\"null\"","liked":"5","isHotelVideo":"false","cityName":"\"null\"","image":"http://s3.amazonaws.com/ravrmedia/Spain/Hot Air Balloon Flight Spain.jpg","thumb":"http://s3.amazonaws.com/ravrmedia/Spain/Hot Air Balloon Flight Spain.jpg","video":"http://s3.amazonaws.com/ravrmedia/Spain/Hot Air Balloon Flight Spain.mp4"},{"id":"4","isWtfVideo":"false","title":"Michelin Chef Susi Diaz at La Finca restaurant","price":"0","description":"\"null\"","liked":"5","isHotelVideo":"false","cityName":"\"null\"","image":"http://s3.amazonaws.com/ravrmedia/Spain/Michelin Chef Susi Diaz at La Finca restaurant.jpg","thumb":"http://s3.amazonaws.com/ravrmedia/Spain/Michelin Chef Susi Diaz at La Finca restaurant.jpg","video":"http://s3.amazonaws.com/ravrmedia/Spain/Michelin Chef Susi Diaz at La Finca restaurant.mp4"},{"id":"5","isWtfVideo":"false","title":"Rafting Spain","price":"0","description":"\"null\"","liked":"5","isHotelVideo":"false","cityName":"\"null\"","image":"http://s3.amazonaws.com/ravrmedia/Spain/Rafting Spain.jpg","thumb":"http://s3.amazonaws.com/ravrmedia/Spain/Rafting Spain.jpg","video":"http://s3.amazonaws.com/ravrmedia/Spain/Rafting Spain.mp4"},{"id":"6","isWtfVideo":"false","title":"Timelapse City of Arts and Sciences","price":"0","description":"\"null\"","liked":"5","isHotelVideo":"false","cityName":"\"null\"","image":"http://s3.amazonaws.com/ravrmedia/Spain/Timelapse City of Arts and Sciences.jpg","thumb":"http://s3.amazonaws.com/ravrmedia/Spain/Timelapse City of Arts and Sciences.jpg","video":"http://s3.amazonaws.com/ravrmedia/Spain/Timelapse City of Arts and Sciences.mp4"}]}

 

asked Jul 14, 2016 in Unity by ibompuis (20 points)

1 Answer

0 votes
HI Ibompuis,

 

Apologies for getting late back to you. It seems like the query which you are creating is not correct. Could you please print the internal logs and share with us. Please use the below line of code just after the key initialization and share the logs which you get in editor console:

 

App42Log.SetDebug(true);

 

Regards,

Himanshu Sharma
answered Jul 16, 2016 by hs00105 (2,005 points)
please find debug
GetInstance Not Null
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:GetInstance()
com.shephertz.app42.paas.sdk.csharp.storage.StorageService:UpdateDocumentByQuery(String, String, Query, String, App42CallBack)
RavrLikeManager:ProcessMedias(String) (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:120)
RavrLikeManager:Update() (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:59)



QueryString is ?
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:ExecutePut(String, Dictionary`2, String, Dictionary`2, Dictionary`2, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.storage.StorageService:UpdateDocumentByQuery(String, String, Query, String, App42CallBack)
RavrLikeManager:ProcessMedias(String) (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:120)
RavrLikeManager:Update() (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:59)



PUT URI : https://api.shephertz.com/cloud/1.0/storage/updateDocsByQuery/dbName/RAVRMEDIAS/collectionName/Spain?
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:ExecutePut(String, Dictionary`2, String, Dictionary`2, Dictionary`2, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.storage.StorageService:UpdateDocumentByQuery(String, String, Query, String, App42CallBack)
RavrLikeManager:ProcessMedias(String) (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:120)
RavrLikeManager:Update() (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:59)



Waiting For Response...
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:ExecutePut(String, Dictionary`2, String, Dictionary`2, Dictionary`2, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.storage.StorageService:UpdateDocumentByQuery(String, String, Query, String, App42CallBack)
RavrLikeManager:ProcessMedias(String) (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:120)
RavrLikeManager:Update() (at Assets/_RAVR_V1/Scripts/RavrLikeManager.cs:59)


errorValue : {"app42Fault":{"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)
com.shephertz.app42.paas.sdk.csharp.connection.<Execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

 errorCodes :
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:HandleException(String, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.connection.<Execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

 appErrorCode "1400"
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:HandleException(String, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.connection.<Execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)


 httpErrorCode "400"
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:HandleException(String, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.connection.<Execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Exception is : com.shephertz.app42.paas.sdk.csharp.App42BadParameterException: {"httpErrorCode":"400", "appErrorCode":"1400", "message":"Bad Request", "details":"The Request parameters are invalid"}
UnityEngine.Debug:Log(Object)
RavrJsonVideoResponse:OnException(Exception) (at Assets/_RAVR_V1/Scripts/RavrJsonVideoResponse.cs:34)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:HandleException(String, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.connection.<Execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Hi Ibompuis,

Thanks for sharing this logs, but the logs are not complete. Could you please share complete logs and also if possible than please share your project which replicates this issue, it will help us to provide better support to you.

Regards,
Himanshu Sharma
Sorry but project are very big and I can't upload it for NDA agreement... also I have provided JSON and and function to call JSON in my first post, I can send you the 2 class if needed by email ?
Is it possible that you can create one sample project which replicates this issue and share with us. It will help us to provide better support to you.

Regards,
Himanshu Sharma
I sended to info@shephertz editor.log and class files
Please share with us at support@shephertz.com.

Regards,
Himanshu Sharma
sended thank you
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
...