simple request for create a device

alireza rahmani7 years ago

hi
please give me a simple post request for example
I tried with this json :

{
    "Device":{
        "name":"gholi",
        "uniqueId" : "asdfghjkl;",
        "status": "",
        "disabled": false

    }
}

and this header : Accept : application/json

and this query : http://192.168.1.103:8082/api/devices

but I give this error:

MessageBodyReadernotfoundformediatype=application/octet-stream,
type=classorg.traccar.model.Device,
genericType=classorg.traccar.model.Device.-MessageBodyProviderNotFoundException(...)

thanks

Anton Tananaev7 years ago

I would recommend you to read documentation. Your JSON is incorrect. You can also check what official web app sends.

alireza rahmani7 years ago

I did but I cant understand
can you give a simple json for that ??
I shoud add all atributes ???

Anton Tananaev7 years ago
alireza rahmani7 years ago

JSON : {"id":-4,"name":"aaa","uniqueId":"iii","phone":"","model":"","contact":"","category":null,"status":null,"lastUpdate":null,"groupId":0,"disabled":false}
ERROR : MessageBodyReadernotfoundformediatype=application/octet-stream, type=classorg.traccar.model.Device, genericType=classorg.traccar.model.Device.-MessageBodyProviderNotFoundException(...)

Anton Tananaev7 years ago

I would recommend you to read error message. It's pretty self explanatory.

alireza rahmani7 years ago

the problem was in header
you should add "Content-Type" in header with "application/json" value