I need to send an image file using rest_command with application/json data payload.
here the data should send:
{
"url":"url of the restful api",
"authorization":"auth bearer for the API",
"to":"phone number",
"type":"media",
"file": {
"name": "filename.jpg",
"data": "base64 encoded jpg file",
"mimetype": "image/jpg"
},
"text": "text to send"
}
I already made a rest_command in configuration.yaml like this:
send_snapshot:
url: '{{url}}'
method: POST
headers:
authorization: '{{authorization}}'
content_type: 'application/json; charset=utf-8'
payload: '{"type":"{{ type }}","text":"{{ text }}","file": {"name": "{{ name }}", "data": "{{ data }}", "mimetype": "{{ mimetype }}"},"to":"{{ to }}"}'
how should I make the script file, if i want to send file on /config/www/tmp/snapshot.jpg
and encoded to bas64 before sending using rest_command.
Thank you