Update Profile Problem in Unity

0 votes

Hi Team,

I am having problem with updateing profile in Unity. I am sending a call for updating the profile using below code:

//This method gets called from button click, which sends a call for updating the profile
public void DoneEditing ()
{
userService = sp.BuildUserService (); // Initializing UserService.
User currentUser = userService.GetUser (GameInfo.info.userName); //getting the current user
 
if (currentUser == null) //if no user is found on the system
return;
 
User.Profile profileObj = (User.Profile)currentUser.GetProfile ();    //Creating object for user profile
profileObj.SetCountry (country.text);   //Setting user's country
 
//selecting gender
if (male != null) {
if (male.isOn) {
profileObj.SetSex (UserGender.MALE);
} else if (female.isOn) {
profileObj.SetSex (UserGender.FEMALE);
}
}
 
//updating the user profile in the server
userService.CreateOrUpdateProfile (currentUser, new EditProfileResponse ());
 
}
 
First time its getting update with "Country" and "Gender" and I can see in shephertz server. But next time when I am trying to update again, its show below exception:
 
Exception : com.shephertz.app42.paas.sdk.csharp.App42BadParameterException: {"httpErrorCode":400, "appErrorCode":1400, "message":"Bad Request", "details":"The Request parameters are invalid"}
 
Please help me.
Thanks,
Somnath Chowdhury.
asked Feb 6, 2015 in App42 Cloud API-BaaS by somnath.chowdhury86 (10 points)

1 Answer

0 votes
Hello Somnath,
 
The exception which you have shared occurs when you have passed wrong or less parameter while making update profile call. So could you please print the internal logs of this method? It will help us to see the root cause of this issue. 
 
 
To print the internal logs of this method, put the below line of code before making update profile call:
 
App42Log.SetDebug(true);
 
Thanks,
Himanshu Sharma
answered Feb 7, 2015 by hs00105 (2,005 points)
This is quite big log I am sending. Don't be scared :D The log is quite big so I am sending in two parts.
First Time when I am updating user's profile I am getting below logs:

Success Case:

apiKeyf28d3b1f380df54fef6627a6f940bb1f879773939256812018079c06802dea85sessionId4cdca1ba-dece-47f5-8aef-bfc443282f61timeStamp2015-02-09T07:07:09.731ZuserNameqweversion1.0
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.util.Util:SortAndConvertTableToString(Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.util.Util:Sign(String, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

QueryString is ?
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

GET URI : https://api.shephertz.com/cloud/1.0%2fuser%2fqwe?
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

OK
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

{"app42":{"response":{"success":true,"users":{"user":{"userName":"qwe","email":"qwe@qwe.com","accountLocked":false,"profile":{"firstName":"","lastName":"","sex":null,"dateOfBirth":null,"mobile":null,"officeLandLine":null,"homeLandLine":null,"line1":null,"line2":null,"city":null,"state":null,"pincode":null,"country":null}}}}}}
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()


Current user: {"app42":{"response":{"success":true,"users":{"user":{"userName":"qwe","email":"qwe@qwe.com","accountLocked":false,"profile":{"firstName":"","lastName":"","sex":null,"dateOfBirth":null,"mobile":null,"officeLandLine":null,"homeLandLine":null,"line1":null,"line2":null,"city":null,"state":null,"pincode":null,"country":null}}}}}}
UnityEngine.Debug:Log(Object)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:55)
UnityEngine.EventSystems.EventSystem:Update()

Created JSOn for Profile : {"app42":{"user":{"profileData":{"firstName":"","lastName":"","sex":"Male","mobile":"null","line1":"null","line2":"null","city":"null","state":"null","country":"China","pincode":"null","homeLandLine":"null","officeLandLine":"null","dateOfBirth":"0001-01-01T00:00:00.000Z"},"userName":"qwe"}}}
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

apiKeyf28d3b1f380df54fef6627a6f940bb1f879773939256812018079c06802dea85body{"app42":{"user":{"profileData":{"firstName":"","lastName":"","sex":"Male","mobile":"null","line1":"null","line2":"null","city":"null","state":"null","country":"China","pincode":"null","homeLandLine":"null","officeLandLine":"null","dateOfBirth":"0001-01-01T00:00:00.000Z"},"userName":"qwe"}}}sessionId4cdca1ba-dece-47f5-8aef-bfc443282f61timeStamp2015-02-09T07:07:11.114Zversion1.0
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.util.Util:SortAndConvertTableToString(Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.util.Util:Sign(String, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

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.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()


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, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

PUT URI : https://api.shephertz.com/cloud/1.0/user/profile?
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, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

Calling: Wait For request callback
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, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

successValue : {"app42":{"response":{"success":true,"users":{"user":{"userName":"qwe","email":"qwe@qwe.com","profile":{"firstName":"","lastName":"","sex":"Male","dateOfBirth":"0001-01-01T00:00:00.000Z","line1":"\"null\"","line2":"\"null\"","city":"\"null\"","state":"\"null\"","pincode":"\"null\"","country":"China","mobile":"\"null\"","homeLandLine":"\"null\"","officeLandLine":"\"null\""}}}}}}
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()

buildResponseForObjectService resource: user
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW:buildResponseForObjectService(String, App42CallBack, String)
com.shephertz.app42.paas.sdk.csharp.connection.<execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()
Next time when I am trying to update with different country or gender its showing below logs.
Failure Case:

apiKeyf28d3b1f380df54fef6627a6f940bb1f879773939256812018079c06802dea85sessionId4cdca1ba-dece-47f5-8aef-bfc443282f61timeStamp2015-02-09T07:12:49.044ZuserNameqweversion1.0
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.util.Util:SortAndConvertTableToString(Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.util.Util:Sign(String, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

QueryString is ?
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

GET URI : https://api.shephertz.com/cloud/1.0%2fuser%2fqwe?
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

OK
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

{"app42":{"response":{"success":true,"users":{"user":{"userName":"qwe","email":"qwe@qwe.com","accountLocked":false,"profile":{"firstName":"","lastName":"","sex":"Male","dateOfBirth":"0001-01-01T00:00:00.000Z","mobile":"\"null\"","officeLandLine":"\"null\"","homeLandLine":"\"null\"","line1":"\"null\"","line2":"\"null\"","city":"\"null\"","state":"\"null\"","pincode":"\"null\"","country":"China"}}}}}}
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync:ExecuteGet(String, Dictionary`2, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:GetUser(String)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:53)
UnityEngine.EventSystems.EventSystem:Update()

Current user: {"app42":{"response":{"success":true,"users":{"user":{"userName":"qwe","email":"qwe@qwe.com","accountLocked":false,"profile":{"firstName":"","lastName":"","sex":"Male","dateOfBirth":"0001-01-01T00:00:00.000Z","mobile":"\"null\"","officeLandLine":"\"null\"","homeLandLine":"\"null\"","line1":"\"null\"","line2":"\"null\"","city":"\"null\"","state":"\"null\"","pincode":"\"null\"","country":"China"}}}}}}
UnityEngine.Debug:Log(Object)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:55)
UnityEngine.EventSystems.EventSystem:Update()

Created JSOn for Profile : {"app42":{"user":{"profileData":{"firstName":"","lastName":"","sex":"Female","mobile":""null"","line1":""null"","line2":""null"","city":""null"","state":""null"","country":"india","pincode":""null"","homeLandLine":""null"","officeLandLine":""null"","dateOfBirth":"0001-01-01T00:00:00.000Z"},"userName":"qwe"}}}
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

apiKeyf28d3b1f380df54fef6627a6f940bb1f879773939256812018079c06802dea85body{"app42":{"user":{"profileData":{"firstName":"","lastName":"","sex":"Female","mobile":""null"","line1":""null"","line2":""null"","city":""null"","state":""null"","country":"india","pincode":""null"","homeLandLine":""null"","officeLandLine":""null"","dateOfBirth":"0001-01-01T00:00:00.000Z"},"userName":"qwe"}}}sessionId4cdca1ba-dece-47f5-8aef-bfc443282f61timeStamp2015-02-09T07:12:50.249Zversion1.0
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
com.shephertz.app42.paas.sdk.csharp.util.Util:SortAndConvertTableToString(Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.util.Util:Sign(String, Dictionary`2)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

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.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()


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, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

PUT URI : https://api.shephertz.com/cloud/1.0/user/profile?
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, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()

Calling: Wait For request callback
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, App42CallBack)
com.shephertz.app42.paas.sdk.csharp.user.UserService:CreateOrUpdateProfile(User, App42CallBack)
EditProfile:DoneEditing() (at Assets/Scripts/CustomCode/EditProfile.cs:73)
UnityEngine.EventSystems.EventSystem:Update()
errorCodes :
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()

appErrorCode 1400
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()

httpErrorCode 400
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()


appErrorCode : "1400"
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()

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)
AssemblyCSharp.EditProfileResponse:OnException(Exception) (at Assets/Scripts/CustomCode/EditProfileResponse.cs:27)
com.shephertz.app42.paas.sdk.csharp.connection.<execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()

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)
AssemblyCSharp.EditProfileResponse:OnException(Exception) (at Assets/Scripts/CustomCode/EditProfileResponse.cs:28)
com.shephertz.app42.paas.sdk.csharp.connection.<execute>d__6:MoveNext()
com.shephertz.app42.paas.sdk.csharp.connection.<WaitForRequest>d__3:MoveNext()

Please reply as soon as possible.
Thnaks.
It seems like player can edit his/her profile only once. This is how shephertz works or player can edit his/her profile as man times as he/she wants?
Hello Somnath,

Apologies for getting late back to you. It seems like there is a bug in the dll, we release the patch by tomorrow & update this thread.

Thanks for your patience.
Himanshu Sharma
Thanks Himanshu for reply.
Hello Somnath,

Patch is available for download, kindly find the latest binary from the below link & let us know if it helps.

https://github.com/shephertz/App42_Unity3D_SDK

Thanks,
HImanshu Sharma
Thanks for update Himanshu. We will get back to you if we face any problem.

Thanks
Somnath
No worry, you can drop a comment in this thread or write us on support@shephertz.com for any query.

Thanks,
HImanshu Sharma
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
...