geosolutions-it / smb-android

GoodGo Android app
GNU General Public License v3.0
2 stars 6 forks source link

Use PUT to register devices #105

Closed giohappy closed 5 years ago

giohappy commented 5 years ago

I've tested the method and it works correctly from Postman. Just call the method with:

my-devices/<registration_id>/

NOTICE: The registration_id must be included in the PUT body too

The curl call is

curl -X PUT \
  http://localhost:8000/api/my-devices/d5KWUs3ZWCs:APA91bGqswQr7PG5lUFyL6GPZ4iEG3OBCtfYqGnxt00BFggso9ugITzi6U7fnI4sU8OwDlFe6hon-OBWs4sFukPTuFPTp5Wo5f9g0yiEm2P-bbEjfQ4NbCXexRYJdmO0XrV7ARIbtsCq/ \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F device_id=3f6456f9dbb34c17 \
  -F registration_id=d5KWUs3ZWCs:APA91bGqswQr7PG5lUFyL6GPZ4iEG3OBCtfYqGnxt00BFggso9ugITzi6U7fnI4sU8OwDlFe6hon-OBWs4sFukPTuFPTp5Wo5f9g0yiEm2P-bbEjfQ4NbCXexRYJdmO0XrV7ARIbtsCq \
  -F type=android

but when called from the app (Android) I get:

2019-09-26 18:02:25.464 30047-30047/it.geosolutions.savemybike E/SaveMyBikeActivity: Can not update firebase token for this Device
    java.lang.Throwable: 500 Internal Server Error
        at it.geosolutions.savemybike.data.server.RetrofitClient$2.onResponse(RetrofitClient.java:231)
        at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

This fixes https://github.com/geosolutions-it/smb-portal/issues/206

giohappy commented 5 years ago

Closing as invalid, since PUT cannot be used for new registration_id