Skip to Content

Send IoT message via HTTPS to HCP by Python script

Hi together,

I have a Raspberry Pi which collects data with some sensors. Now I want to post these sensor data via HTTPS request to HCP. But how?

I tried using a Python script from the iot-starterkit but there I would have to use a certificate but my HCP trail account doesn't support certificates. Now I got the information that it should also be possible to authenticate my Raspberry Pi via the OAuth access token. How can I achieve that? How do I have to use Certifi correctly?

BR
Simon

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 24, 2017 at 04:56 PM

    Hello Simon, in the example you have referenced, "certifi" python package is used for validation when building the http connection (you just install it with pip). But you authenticate your call with OAuth (see line #25). That bearer token you get when you register your device in IoT Cockpit. So, that example is exactly what you need - it sends your sensor data to HCP over HTTPS. Regards, Anton

    Add comment
    10|10000 characters needed characters exceeded

    • This seemed to help. Connection is now established, anyway I get error code 400 from the server. Maybe my string is not correct. But this I'll post in another question if I don't find the error. Thanks for help with HTTPs problem. :-)

  • Jan 24, 2017 at 09:57 PM

    Hi Simon! thanks for writing the question. In addition to what Anton said here, my colleagues suggested you have a look at these references:

    Documentation on connectivity services of HCP:

    https://help.hana.ondemand.com/help/e54cc8fbbb571014beb5caaf6aa31280.html

    On certificate-based communication:

    https://help.hana.ondemand.com/help/frameset.htm?3f1247537c1a4f069235ee63633659c5.html or https://help.hana.ondemand.com/help/frameset.htm?9018a9e54b3c48d98aa63538d47bdcd6.html depending on whether it is a client or a server configuration.

    thanks!

    Add comment
    10|10000 characters needed characters exceeded