Search code examples
androidgigya

Gigya ids.setAccountInfo error Schema validation failed


i am trying to set account data
i use ids.setAccountInfo

            GSObject param = new GSObject();
            GSObject profile = new GSObject();
            param.put("UID", user.getString("UID"));
            profile.put("firstName", "FirstName");
            param.put("profile", profile);
            GSAPI.getInstance().sendRequest("ids.setAccountInfo", param, new GSResponseListener() {
                @Override
                public void onGSResponse(String s, GSResponse gsResponse, Object o) {
                    Log.d("ids.setAccountInfo", "----------------------------");
                    Log.d("ids.setAccountInfo", "s " + s);
                    Log.d("ids.setAccountInfo", "gsResponse " + gsResponse);
                    Log.d("ids.setAccountInfo", "----------------------------");
                }
            }, null);

and have response

    errorCode:400006
errorMessage:Invalid parameter value
errorDetails:Schema validation failed
data:{"validationErrors":[{"message":"write access mode violation","fieldName":"profile.firstName","errorCode":400025}],"statusCode":400,"errorMessage":"Invalid parameter value","time":"2015-08-13T11:48:14.664Z","errorDetails":"Schema validation failed","statusReason":"Bad Request","errorCode":400006,"callId":"e0ed6aebea144323b095849ae3ed40ee"}

If I send empty profile or not send it then success

errorCode:0
errorMessage:null
errorDetails:null
data:{"statusCode":200,"errorCode":0,"time":"2015-08-13T11:53:19.738Z","callId":"e59b00cd09bf48a398586219f817930d","statusReason":"OK"}

Solution

  • Since the call to ids.setAccountInfo is done from a client side (presuming android SDK is used) while the profile schema for these fields write access is 'serverOnly' or 'clientCreate'. In order for this to work these fields needs to have the 'clientModify' write access.

    Get the schema with ids.getSchema and look in fields write access.

    It is possible to change that with a call to ids.setSchema, look in link for further details.

    writeAccess - Specifies whether to allow unsigned requests to write into this field. This property applies when using the ids.getAccountInfo method, or when setting fields through the usage of a Screen-Set. The supported values are:

    • "serverOnly" (default) - Only signed requests coming from the server are allowed.
    • "clientCreate" - Unsigned requests coming from the client are allowed to write into this field, only if it wasn't set before.
    • "clientModify" - Unsigned requests coming from the client are allowed to write into this field and modify existing values.