Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Parse installation object removes it

I create an installation object using a REST API call like this :

curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
    "deviceType": "ios",
    "deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "channels": [
      ""
    ]
  }' \
https://<your.parseprovider.here>/1/installations

The installation object is created and is indicated by the response :

{
"objectId": "EmqGmZXGEm",
"createdAt": "2017-02-15T10:13:18.647Z"
}

Now let's say I want to update the channels field to include the "foo" channel in the installation object, I could simply issue a call like :

curl -X PUT \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
    "channels": [
      "",
      "foo"
    ]
  }' \
https://<your.parseprovider.here>/1/installations/EmqGmZXGEm    

Success is then indicated by the response :

{
"updatedAt": "2017-02-15T10:18:31.055Z"
}

However, when I execute the PUT call like this (as in the REST API docs, note the inclusion of the deviceType and deviceToken fields) :

curl -X PUT \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
    "deviceType":"ios", 
    "deviceToken":"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "channels": [
      "",
      "foo"
    ]
  }' \
https://<your.parseprovider.here>/1/installations/EmqGmZXGEm

I now get the following response :

{
"code": 101,
"error": "Object not found."
}

The installation object has now suddenly been deleted from the Parse server database.

This seems to happen as soon as the deviceToken field is included in the PUT request.

Is this supposed to happen, or am I missing something? I am using a Parse API for Delphi which is breaking because of this "phenomenon". I would rather not hack the API if the error is due to a Parse bug that should be fixed on the server side.

like image 772
Edrean Ernst Avatar asked Feb 15 '17 10:02

Edrean Ernst


1 Answers

Try PATCH instead of PUT. See table. Both PUT and PATCH can be used for update.

like image 195
SACn Avatar answered Nov 20 '22 03:11

SACn