Skip to Content

Call SAP IoT Application Enablement API from local Python file

Hi all,

Does anyone know how to call an API URL with python code locally?

I am trying to write a python code to call a SAP IoT Application Enablement API (to read historical data of a PropertySetType of a Thing) and to be executed locally.

I am facing an authentication issue: I first get the "X-Uaa-Csrf" cookie with get method, and then I authenticate with post method (with username, password and "X-Uaa-Csrf" payload) with the authentication URL.

Then I try to call the API URL with get method: the status code is 200, while the response is not the expected one (the one I get in json format by copying and pasting the API URL in the browser), but it is an html response with a login callback in the redirected uri..

Thanks and BR,

Fabio

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 21 at 09:19 AM

    The blog at https://blogs.sap.com/2017/10/13/access-the-sap-iot-application-enablement-apis-using-postman/ illustrates how to get an OAuth Token to make calls. This is meant for server to server calls without user context.

    For Nodejs there is a library that simplifies this here https://github.com/SAP/iot-application-services-sdk-nodejs .

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 21 at 09:20 AM

    ... are you looking to use python for some data analysis locally? Python offers many statistical libraries.

    Add comment
    10|10000 characters needed characters exceeded