2015-06-08 40 views
0

我想從parse.com的_User表中刪除一個用戶,但出現錯誤。如何通過Parse REST API從_User中刪除用戶

我敢肯定,要求的語法是好的,我得到這個錯誤:

code: 206 
error: "Parse::UserCannotBeAlteredWithoutSessionError" 

我想我不應該做的登錄到刪除用戶,因爲我在API REST上執行。

$scope.delete = function (id) { 
    $http({ 
    method: "DELETE", 
    url: url_users + id, 
    headers: {'X-Parse-Application-Id': appId, 
       'X-Parse-REST-API-Key': restId} 

    }).success(function (data) { 
    debugger; 
    swal("Deleted!", "All user data has been deleted", "success"); 
    }).error(function (data) { 
    debugger; 
    swal("Error!", "An unexpected error ocurred, try again!", "error"); 
    }); 
} 

回答

0

我沒有試過這樣做,但我有這些想法:

  • 確保您的ACL允許該給公衆
  • 它是不能接受的調用雲碼功能?這比我在這種情況下使用API​​更直觀。你能解釋一下爲什麼你必須使用使用REST API嗎?
  • 如果不行,看看這個答案:https://www.parse.com/questions/delete-a-user-rest-api

基本上,你可能需要通過主鍵頭,這是不太理想暴露給公衆。是不是接受

1

您試圖從不同的用戶會話中刪除用戶以刪除。即使您在標頭中使用X-Parse-REST-API-Key,這也不適用於REST API。解決方案是使用Clode Code Function從另一個會話中刪除或更新用戶。

欲瞭解更多信息,請參閱文檔Parse Cloud Code Guide

以下響應代碼Clode功能來刪除用戶:

Parse User Destroy - Javascript in Cloud Code

+0

請給你的回答更多的細節和使用各環節作爲參考,詳情請參閱http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers。 – Panda