Hi all,
Is it possible to call OData Web API service from outside SAP BTP?
I have generated a table in ABAP cloud (SAP BTP trial). Simple OData Web API was generated as well. I can get json response in browsers (after providing username and password).
“@odata.context”: “$metadata”,
“value”: [
{
“name”: “ZC_TSENSORDAT_GIV”,
“url”: “ZC_TSENSORDAT_GIV”
}
]
}
However, I tried to call the API in Python script with Basic Auth I don’t get expected json as in browser. So, I assumed, the API requires an OAuth authorization. I decided to generate XSUAA instance, which can generate tokens for authorization.
Instance was generated successfully. JSON content for XSUAA is as follows:
“xsappname”: “xsuaa_iot”,
“tenant-mode”: “dedicated”,
“scopes”: [
{
“name”: “$XSAPPNAME.Viewer”,
“description”: “Read access to sensor data”
},
{
“name”: “$XSAPPNAME.Admin”,
“description”: “Full access to sensor data”
}
],
“role-templates”: [
{
“name”: “Viewer”,
“description”: “Read-Only Role”,
“scope-references”: [“$XSAPPNAME.Viewer”]
},
{
“name”: “Admin”,
“description”: “Full Access Role”,
“scope-references”: [“$XSAPPNAME.Admin”]
}
],
“oauth2-configuration”: {
“redirect-uris”: [
“https://{………..}hana.ondemand.com/login/callback”
]
},
“authorities”: [
“$XSAPPNAME.Viewer”,
“$XSAPPNAME.Admin”
]
}
A custom role collection was created and was assigned to my SAP BTP user ( Admin and Viewer roles ). So I added to my Python script a logic for token request from XSUAA and sending it to OData Web API. However, the API responds with redirect to page with username and password request. Looks like API doesn’t accept the token.
Where am I doing wrong? Any suggestions would be appreciated.
Best regards,
Ihor