Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Content type text/html not supported #68

Open
EleanorRigby opened this issue Mar 20, 2020 · 10 comments
Open

Content type text/html not supported #68

EleanorRigby opened this issue Mar 20, 2020 · 10 comments
Labels

Comments

@EleanorRigby
Copy link

EleanorRigby commented Mar 20, 2020

Describe the bug

When trying to open a new connection through session API

session_api = VSphereAutomation::CIS::SessionApi.new(api_client)

The API client errors out saying Content-Type is not supported: text/html
in vsphere-automation-vcenter-0.1.0/lib/vsphere-automation-vcenter/api_client.rb:159:in `deserialize'

How to reproduce

vCenter version : Version 6.5.0.30000 Build 14020092

Used automation-sdk version 0.1.0

ruby 2.4.2

# minimal code to reproduce issue

Expected behavior

Error should not occur

Versions

Dev Environment:

  • Ruby: 2.4.2
  • vSphere Automation SDK: 0.1.0
  • OS: Linux Ubuntu Xenial/Trusty

Additional notes

Rescued Unknown: Content-Type is not supported: text/html. 
backtrace: /var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/vendor/bundle/ruby/2.4.0/gems/vsphere-automation-vcenter-0.1.0/lib/vsphere-automation-vcenter/api_client.rb:159:in `deserialize'
/var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/vendor/bundle/ruby/2.4.0/gems/vsphere-automation-vcenter-0.1.0/lib/vsphere-automation-vcenter/api_client.rb:71:in `call_api'
/var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/vendor/bundle/ruby/2.4.0/gems/vsphere-automation-cis-0.1.0/lib/vsphere-automation-cis/api/session_api.rb:61:in `create_with_http_info'
/var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/vendor/bundle/ruby/2.4.0/gems/vsphere-automation-cis-0.1.0/lib/vsphere-automation-cis/api/session_api.rb:26:in `create'
/var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/lib/cloud/vsphere/attach_tag_to_vm.rb:108:in `InitializeConnection'
/var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/lib/cloud/vsphere/cloud.rb:128:in `initialize'
/var/vcap/data/packages/vsphere_cpi/867e8ca374165990ba78024886d77673ecd871f4/lib/cloud/vsphere.rb:92:in `new'
@EleanorRigby
Copy link
Author

cc: @SanikaGawhane @ktchen14

@EleanorRigby
Copy link
Author

@jrgarcia : Any idea why would VC return a text/html instead of application/json? I have not seen this in our VMware dev pipelines but the customer is reporting seeing it.

@swagataroy
Copy link

vCenter Version is 6.5.0.30000 Build 14020092

@jrgarcia
Copy link
Contributor

@EleanorRigby The only instance where this would be likely to happen would be if the configuration object is misconfigured. Can you send me what is being used for the configuration? It doesn't appear that it would change anything for this particular issue, but I would also suggest using a newer version than v0.1.0.

@EleanorRigby
Copy link
Author

         configuration = VSphereAutomation::Configuration.new.tap do |config|
           config.host = cloud_config.vcenter_host
           config.username = cloud_config.vcenter_user
           config.password = cloud_config.vcenter_password
           config.scheme = 'https'
           config.verify_ssl = false
           config.verify_ssl_host = false
           config.logger = logger
           config.debugging = false
        end
        api_client = VSphereAutomation::ApiClient.new(configuration)
        api_client.default_headers['Authorization'] = configuration.basic_auth_token
        session_api = VSphereAutomation::CIS::SessionApi.new(api_client)
        session_id = session_api.create('').value
        api_client.default_headers['vmware-api-session-id'] = session_id
        api_client

@EleanorRigby
Copy link
Author

@jrgarcia
Copy link
Contributor

@EleanorRigby That looks correct. What is the value of cloud_config.vcenter_host? The most likely culprit would be that the host is not set up correctly and it is creating the URL incorrectly. I have seen cases where vCenter will return text/html in cases of making a call that results in a server-side error.

@EleanorRigby
Copy link
Author

@jrgarcia : I think that info is on customer env and will need to be fetched.

@swagataroy : Can we get what was vcenter_host set to in cpi config?

@EleanorRigby
Copy link
Author

@jrgarcia : Do you think presence of http/s scheme or trailing / can cause the problem?

@jrgarcia
Copy link
Contributor

@EleanorRigby The scheme should be correct as long as their vCenter is actually available on https, which hopefully it is. It is concerning that SSL verification is set to false by default. That's a security issue. I'm not sure if a trailing / alone would cause an issue, but ideally the host would be nothing more than the hostname with no scheme or slashes. Just a hostname.

@jrgarcia jrgarcia removed their assignment Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants