I get this error message when I want to use the POST method for AddUsernamePassword in my cloud script:
"FunctionResult": { "code": 400, "status": "BadRequest", "error": "AccountAlreadyLinked", "errorCode": 1011, "errorMessage": "User already linked to a different account" }
function AddUsernamePasswordFromCloudScript(sessionticket, email, username, password, playFabId) { var contentBodyTemp = { "PlayFabId": playFabId, "Email": email, "Username": username, "Password": password }; let url = "https://E5E2C.playfabapi.com/Client/AddUsernamePassword"; let method = "POST"; let contentBody = `{"PlayFabId": "${playFabId}", "Email": "${email}", "Username": "${username}", "Password": "${password}"}`; let contentType = "application/json"; let headers = { "X-Authentication": sessionticket }; let responseString = http.request(url, method, contentBody, contentType, headers); let responseJSONObj = JSON.parse(responseString); return (responseJSONObj); if (responseJSONObj.Error == null) return "true"; else { log.info("Error code: " + responseJSONObj.error.toString()); // return error code to client. return responseJSONObj.error; } }
At the beginning, I use PlayFabClientAPI.LoginWithAndroidDeviceID with CreateAccount = true to create a new account when a player starts my game the very first time. Later, the player needs to add email, username and password and therefore I use the POST method in my cloud script. In addition, the player should have the possibility to change email, username and password on a later date if he wants. But I always get this error message when the player wants to change his email, username and password. I have already tried to unlink and link the device again in the client code but it still doesn't work. I always get the error message "User already linked to a different account".
Can I use the POST method for AddUsernamePassword only once when the new account is created? Is it not possible to use it again when the player wants to change his email, username and password?