watson-developer-cloud / python-sdk

:snake: Client library to use the IBM Watson services in Python and available in pip as watson-developer-cloud
https://pypi.org/project/ibm-watson/
Apache License 2.0
1.46k stars 827 forks source link

CloudPakForDataAuthenticator not working with CPD 3.5.3 #801

Closed greenertux closed 2 years ago

greenertux commented 3 years ago

Overview AddDocument does not work with the sample code from the docs. It works via curl so the issue seems to be in the python sdk.

Expected behavior Document should be added

Actual behavior ibm_cloud_sdk_core.api_exception.ApiException: Error: 3.5.0.0 (20210707_1654) x86_64 , Code: 404

How to reproduce I have used the example code as attached.

SDK Version 5.2.2

Additional information: RHEL8, x86_64 Python 3.7

Additional context The following curl works flawlessly (replaced sensitive info by XXX): curl -X POST -H "Authorization: Bearer XXX" -F "file=@53.pdf" -F metadata="{\"field_name\": \"content\"}" "https://XXX/discovery/zen-wd/instances/1629915333563050/api/v2/projects/ab1e81a4-f26e-4b11-b3df-9da84e90a64f/collections/da94a9b8-bfe3-3bff-0000-017b7e88762c/documents?version=2019-11-29" --insecure

This is the code I ran: test.py.txt

This is the command line output I got: output.txt

greenertux commented 3 years ago

I have updated the title as I have found the problem already lies in the CloudPakForDataAuthenticator. When I update the URL to include the zen workspace (https://XXX:443/zen instead of just https://XXX:443) I get the error "Cannot POST /auth/login/sso). When I access https://XXX/zen/api/v2/auth/login/sso I get a HTTP 404 error.

greenertux commented 3 years ago

I have been able to get my script working by switching to BearerTokenAuthenticator

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.