Toml parse soap request as string

telegraf
#1

Hi ,

Im trying to send soap request by using the [[inputs.http_response]] plugin .
Im having an issue with parsing the body correctly.
how can i parse this body with the quotes and without new line

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://XXXX/">
   <soapenv:Header/>
   <soapenv:Body>
      <tlv:IsUserExist>
         <tlv:user>
            <tlv:UserName>XXXX</tlv:UserName>
          
         </tlv:user>
      </tlv:IsUserExist>
   </soapenv:Body>
</soapenv:Envelope>
#2

Can you add your configuration for the http_response plugin?

#3

this config will generate error

2017-08-15T06:19:20Z E! Error in plugin [inputs.http_response]: Post http://iisnlb/TlvBusinessLogic/Applications/Integration/ActiveDirectory/InterfaceToADService.asmx: net/http: invalid header field value "\\\n <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tlv=\"http://Tlv.Integration.Servies.ActiveDirectory/\">\\\n <soapenv:Header/>\\\n <soapenv:Body>\\\n <tlv:IsUserExist>\\\n <tlv:user>\\\n <tlv:UserName>XXXX</tlv:UserName>\\ \n </tlv:user>\\\n </tlv:IsUserExist>\\\n </soapenv:Body>\\\n</soapenv:Envelope>\\\n" for key Body

Config

#HTTP/HTTPS request given an address a method and a timeout
 [[inputs.http_response]]

   address = "XXXXX"

   response_timeout = "10s"

   method = "POST"
   [inputs.http_response.headers]
     "SOAPAction" = "XXXX"
     "Content-type" = "text/xml; charset=utf-8"
       
### Optional HTTP Request Body
        body = '''\
         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tlv="http://Tlv.Integration.Servies.ActiveDirectory/">\
       <soapenv:Header/>\
       <soapenv:Body>\
          <tlv:IsUserExist>\
             <tlv:user>\
                <tlv:UserName>XXXX</tlv:UserName>\     
             </tlv:user>\
          </tlv:IsUserExist>\
       </soapenv:Body>\
    </soapenv:Envelope>\
    '''
#4

Try moving the body above the [inputs.http_response.headers] section, otherwise it becomes part of the headers section. I’ll update the sample configuration file since it recommends this incorrect ordering.

1 Like