REST post as service, error

Hey Guys,

i am struggling with Rest integration trying to make a service to make a post. i have curl and URL example that work but cant get it working when service is called. Any tips? thanks a bunch!

the log show URL status code 500. I can copy and past the URL in browser and works.

Logger: homeassistant.components.rest_command
Source: components/rest_command/__init__.py:133
Integration: RESTful Command (documentation, issues)
First occurred: 1:42:23 PM (2 occurrences)
Last logged: 2:05:48 PM

Error. Url: https://voip.ms/api/v1/rest.php?api_username=myuser&api_password=andpass&method=sendSMS&did=1234567891&dst=1111111111&message=test. Status code 500.
Home Assistant has started!

Configuration

rest_command:
  my_request:
    url: https://voip.ms/api/v1/rest.php
    method: POST
    headers:
      Content-Type:  'application/json'
    payload: '{"api_username": "myuser", "api_password": "andpass", "method": "sendSMS", "did": "1234567891", "dst": "1111111111", "message": "hass test"}'
    verify_ssl: true

eventually with variable i can call service with data, but for now not important.

    payload: '{"api_username": "myuser", "api_password": "andpass", "method": "sendSMS", "did": "1234567891", "dst": "{{ dst }}", "message": "{{ msg }}"}'

{
"dst": "123456351",
"msg": "hass test"
}

i saw another example i thought may work but didnt

rest_command:
  my_request:
    url: https://voip.ms/api/v1/rest.php?api_username=myuser&api_password=andpass&method=sendSMS&did=1234567891&dst=1111111111&message=test
    method: POST

=====================================
working curl example of the API:

$postfields = array(
    'api_username'=>'myuser',
    'api_password'=>'andpass',
    'method'=>'sendSMS',
    'did'=>'1234567891',
    'dst'=>'1111111111',
    'message'=> 'test'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_URL, "https://voip.ms/api/v1/rest.php");
$result = curl_exec($ch);
curl_close($ch);
$data=json_decode($result,true); //success or fail error
print_r($data);

=----------
working url

https://voip.ms/api/v1/rest.php?api_username=myuser&api_password=andpass&method=sendSMS&did=1234567891&dst=1111111111&message=test

Well its starting to seem like user error here, specifically lack of understanding how apis and or curl works.

I assume by looking at curl php code is curl POST method, and i can specify data or payload/json. i dont know. using GET here is working, and with variables. that may explain why i can never get curl on command line working -X POST. I thought i could use curl GET with --data ‘{“msg”:“test”}’ but didn’t work.

rest_command:
  my_request:
    url: https://voip.ms/api/v1/rest.php?api_username=myuser&api_password=andpass&method=sendSMS&did=1234567891&dst={{ dst }}&message={{ msg }}
    method: GET

anyway hope it helps some other confused person like i was. thanks!

Anyway,