not working command send

traccargps12 years ago

Hi,

I'm using react native

New Session Login - OK
Use GET to http://xx.xx.xx.xx:8082/api/commands/send?deviceId=0. - OK

but not workign command send

http://xx.xx.xx.xx:8082/api/commands?deviceId=5&type=custom&attributes=ST300CMD;Res;number_device;407;Enable1

Status Code: 400
Method: POST

http://xx.xx.xx.xx:8082:8082/api/commands/send?deviceId=5&type=custom&attributes=%5Bobject%20Object%5D

OBS: attributes={"data": "ST300CMD;Res;number_device;Enable1"}
Status Code: 400
Method: POST

I looked at the documentation but I still can't pass the correct command
https://www.traccar.org/api-reference/#tag/Commands/paths/~1commands~1send/post

Anton Tananaev2 years ago

You probably missed this part from the documentation:

REQUEST BODY SCHEMA: application/json

traccargps12 years ago

hi,
well noted (REQUEST BODY SCHEMA: application/json) thanks , I made the adjustment and put it similar code to the post session which is in react native.
but not working.

resquest

deviceId=5&type=custom&attributes=%7B%22data%22%3A%22ST300CMD%3BRes%3Bnumber_device%3B407%3BDisable1%22%7D

obs: number_device = my number ok i change.  attributes = '{"data":"ST300CMD;Res;number_device;407;Disable1"}',

request reader

content-type. application/json;charset=UTF-8

response header

access-control-allow-methods  GET, POST, PUT, DELETE, OPTIONS
Content-Length  240
Content-Type   text/plain
Date. Sun, 09 Oct 2022 15:18:44 GMT
access-control-allow-credentials. true
access-control-allow-headers   origin, content-type, accept, authorization
access-control-allow-origin *
Server J etty(10.0.7)

it is necessary to send the 'id' field ??

traccargps12 years ago

hi,

I made the following adjustments and now I get the Status Code 200 response.

  • adjustments 01 (Thanks Anton)
   content-type. application/json;charset=UTF-8
        var details = {
            'deviceId': 5,
            'type': 'custom',
            "attributes": {"data":"ST300CMD;Res;device_number;407;Enable1"}
        };
body: JSON.stringify(details)
traccargps1a year ago

it worked had to adjust to the correct command