Understanding rest_command

Hi there,

I’m using a rest_command very similar to the example given in the documentation here.

# Example configuration.yaml entry
rest_command:
  my_request:
    url: https://slack.com/api/users.profile.set
    method: POST
    headers:
      authorization: !secret rest_headers_secret
      accept: "application/json, text/html"
      user-agent: 'Mozilla/5.0 {{ useragent }}'
    payload: '{"profile":{"status_text": "{{ status }}","status_emoji": "{{ emoji }}"}}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: true

The implementation is working accept that my log is getting filled with the following warning:

Template variable warning: 'useragent' is undefined when rendering 'Mozilla/5.0 {{ useragent }}'

I tried to get a better understanding what this means but I didn’t succeed. I imagine that in

user-agent: 'Mozilla/5.0 {{ useragent }}'

{ useragent } remains empty in my setup.

How is this suppose to work and for what purpose?

Can this be because I’m behind a proxy?

In the example, useragent is supposed to have been set somewhere else.
In your case, just remove the user-agent: altogether or, in the very rare case the target requires a specific one, just hardcode the full user-agent.

Thanks @koying :slight_smile: