Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

href of entity set respected? #161

Open
rene312 opened this issue Jul 14, 2021 · 5 comments
Open

href of entity set respected? #161

rene312 opened this issue Jul 14, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@rene312
Copy link

rene312 commented Jul 14, 2021

Hello,

I am trying to access the entity set “APIs” of https://api.sap.com/odata/1.0/catalog.svc/

If I execute https://api.sap.com/odata/1.0/catalog.svc/ in the browser I get

APIs

However if I execute

client.entity_sets.APIs.get_entities().execute()

in python while tracing the url’s I see:

https://api.sap.com:443 "GET /odata/1.0/catalog.svc/APIs HTTP/1.1" 200 None

this naturally does not work as the URL path should be https://api.sap.com/odata/1.0/catalog.svc/APIContent.APIs/ (which does work in the browser).

Am I using the API wrong? What should I be executing instead of client.entity_sets.APIs.get_entities().execute() ?

Best regards,
Rene.

@phanak-sap
Copy link
Contributor

phanak-sap commented Jul 19, 2021

Hi @rene312, could you please enable logging and provide the request and the response: https://pyodata.readthedocs.io/en/latest/usage/advanced.html#enable-logging

If from logging will be apparent that it is certificate problem (just a guess from the info so far), check https://pyodata.readthedocs.io/en/latest/usage/initialization.html

@phanak-sap phanak-sap added the question Further information is requested label Jul 19, 2021
@rene312
Copy link
Author

rene312 commented Jul 20, 2021

py_odata_trace.txt
Hi Phanak,
I have attached the trace.
There are no authorization problems before the access of the invalid url https://api.sap.com/odata/1.0/catalog.svc/APIs.
I also spoke to the person responsible for the security of https://api.sap.com/odata/1.0/catalog.svc/ and he stated that no authorization / logon / certificates are required to access the resources.
I have also verified this in a sandboxed browser with no certificates installed.
However attempting to access invalid url's seems to trigger SAML authentication. I have not found a way to suppress this.
i.e. does the library attempt to access the invalid url /odata/1.0/catalog.svc/APIs and only if that fails access the correct one https://api.sap.com/odata/1.0/catalog.svc/APIContent.APIs/ ? I am not sure if I can get this working if the library does that.
Best regards,
Rene.

@rene312
Copy link
Author

rene312 commented Jul 20, 2021

Hi Phanak,

Search through the trace, I see that we have

Though client.entity_sets.APIs exists as method.

Rene.

@jfilak
Copy link
Contributor

jfilak commented Jul 21, 2021

Ooops, PyOData supports only 1 schema per Metadata:

edm_schemas = xml.xpath('/edmx:Edmx/edmx:DataServices/edm:Schema', namespaces=self._config.namespaces)

@phanak-sap phanak-sap added bug Something isn't working and removed question Further information is requested labels Aug 23, 2021
@habbler
Copy link

habbler commented Aug 27, 2021

I am not so familiar with oData or Python, but the following worked in my case. Don't know if it breaks other cases:

I added the lines

    if alias is None:
        self._alias = entity_set._entity_type_info.namespace + '.' + entity_set.name    
    else:    
        self._alias = alias

to method def init of class EntitySetProxy as shown below.

class EntitySetProxy:
"""EntitySet Proxy"""

def __init__(self, service, entity_set, alias=None, parent_last_segment=None):
    """Creates new Entity Set object

        @param alias  in case the entity set is access via assossiation
        @param parent_last_segment  in case of association also parent key must be used
    """
    self._service = service
    self._entity_set = entity_set
    if alias is None:
        self._alias = entity_set._entity_type_info.namespace + '.' + entity_set.name    
    else:    
        self._alias = alias
    if parent_last_segment is None:
        self._parent_last_segment = ''
    else:
        if parent_last_segment.endswith('/'):
            self._parent_last_segment = parent_last_segment
        else:
            self._parent_last_segment = parent_last_segment + '/'
    self._name = entity_set.name
    self._key = entity_set.entity_type.key_proprties
    self._logger = logging.getLogger(LOGGER_NAME)

    self._logger.debug('New entity set proxy instance for %s', self._name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants