Help with XML format

Hi,

I’m trying to send an API request using XML to a Hikvision camera. I have it working with a simple request, but I can’t get it to work with a more complex request.

This is the output when sending a GET request for the simple request:

<?xml version="1.0" encoding="UTF-8"?>
<Shutter version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
    <ShutterLevel>1/25</ShutterLevel>
</Shutter>

I send the following PUT command via the shell command which works perfectly:

curl -s --basic "http://user:[email protected]/ISAPI/Image/channels/1/shutter" -X PUT -H "Content-Type: text/xml; charset=UTF-8" -d "<?xml version="1.0" encoding="UTF-8"?><ShutterLevel>1/25</ShutterLevel>"

This is the output from the more complex request:

<?xml version="1.0" encoding="UTF-8"?>
<VideoOverlay version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
    <normalizedScreenSize>
        <normalizedScreenWidth>704</normalizedScreenWidth>
        <normalizedScreenHeight>576</normalizedScreenHeight>
    </normalizedScreenSize>
    <attribute>
        <transparent>false</transparent>
        <flashing>false</flashing>
    </attribute>
    <TextOverlayList size="4">
        <TextOverlay>
            <id>1</id>
            <enabled>true</enabled>
            <positionX>670</positionX>
            <positionY>352</positionY>
            <displayText>*********My Text Here*********</displayText>
            <directAngle></directAngle>
        </TextOverlay>
    </TextOverlayList>
    <DateTimeOverlay>
        <enabled>true</enabled>
        <positionX>572</positionX>
        <positionY>576</positionY>
        <dateStyle>DD-MM-YYYY</dateStyle>
        <timeStyle>12hour</timeStyle>
        <displayWeek>false</displayWeek>
    </DateTimeOverlay>
    <channelNameOverlay>
        <enabled>false</enabled>
        <positionX>512</positionX>
        <positionY>64</positionY>
        <name></name>
    </channelNameOverlay>
    <fontSize>adaptive</fontSize>
    <frontColorMode>customize</frontColorMode>
    <frontColor>ffffff</frontColor>
    <alignment>allRight</alignment>
    <boundary>1</boundary>
    <upDownboundary>0</upDownboundary>
    <leftRightboundary>0</leftRightboundary>
</VideoOverlay>

I’m trying to change the displaytext under textoverlay. I’ve tried so many variations, but no bueno. I’ve even tried using a single line converter to convert the whole output to a single line and send that, but that doesn’t work. It works if I edit the output from the GET request then send it back as a PUT request.

I ended up using the rest command in the end. I’m not sure why it wouldn’t work with the shell command. It’s a lot easier to read and format the rest command as it’s not on single line.

rest_command:
  rest_overlay:
    url: "http://user:[email protected]/ISAPI/System/Video/inputs/channels/1/overlays"
    method: PUT
    payload: <?xml version="1.0" encoding="UTF-8"?>
      <VideoOverlay version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
      <TextOverlayList size="4">
      <TextOverlay>
      <id>1</id>
      <enabled>true</enabled>
      <positionX>680</positionX>
      <positionY>576</positionY>
      <displayText>{{ states('sensor.camera_overlay_rh') }}</displayText>
      <directAngle></directAngle>
      </TextOverlay>
      </TextOverlayList>
      </VideoOverlay>