Updating Parse installation object removes it
Asked Answered
S

1

11

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.

Salzman answered 15/2, 2017 at 10:38 Comment(1)
I really have no clue, however, reading the docs makes me wonder if you have sent a query to GET to get a list of installations to ensure you are referring to valid stuff.Often
P
1

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

Phiz answered 28/2, 2017 at 7:34 Comment(1)
Unfortunately this does not work. When I use PATCH instead of PUT the reply is : {"message":"Not Found","error":{}}Salzman

© 2022 - 2024 — McMap. All rights reserved.