Five9's API: How to pull reports using SOAP API and Basic Authentication

前端 未结 3 2030
旧巷少年郎
旧巷少年郎 2021-02-04 17:33

We are trying to access data from Five9\'s server using there reporting API. We have written code below but are not getting any results. To me it looks like issue is with the Au

3条回答
  •  星月不相逢
    2021-02-04 18:24

    It looks like your problem is that your sending your base64 encoded username/password in the soap header. It actually needs to be included in the http header. My solution is in ruby but hopefully it can help you out.

    soap_client = Savon.client(
      endpoint: "https://api.five9.com/wsadmin/AdminWebService/", 
      namespace: "http://service.admin.ws.five9.com/", 
      headers: { "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" }, 
      env_namespace: :soapenv, 
      namespace_identifier: :ser, 
      ssl_verify_mode: :none
    )
    
    message = { 
      "lookupCriteria" => {
    "criteria" => {
          "field" => "email_address",
          "value" => "something@example.com"
        }
      }
    }
    
    response = soap_client.call(:getContactRecords, message: message)
    p response.body
    

    So your XML ends up looking like this.

    SOAP request: https://api.five9.com/wsadmin/AdminWebService/
    Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==, SOAPAction: "getContactRecords",
    Content-Type: text/xml;charset=UTF-8, Content-Length: 471
    
    
    
      
        
          
            
              email_address
              something@example.com
            
          
        
      
    
    
    HTTPI POST request to api.five9.com (httpclient)
    SOAP response (status 200)
    
    
      
      
        
          
            number1
            email_address
            
              
                5555555555
                something@example.com
              
            
          
        
      
    
    

提交回复
热议问题