Not able to Register the product on Cumulocity using python

Hello All,

Actually our product is registered on the Cumulocity. Which is written in C/C++.

But I am trying to learn it and writing in python. I am trying to connect on the Cumulocity server. Our product is already one time registered but then I have deleted from the server. So it can consider as a fresh connection. I have deleted all the configuration of the particular product.

As per old product logs, I can see first basic authentication. We have to send URL, and ca-certificate to basic handshake (Means includes TLS1.2 or TLS1.3 authentication).

As a second step we have to send the payload in the rest API format and that is as bootstrapagent.

Which I am not able to do. Due to lack of knowledge in the REST API.

For that we are using below macros
BOOTSTRAP_HOST = “”
BOOTSTRAP_PORT = 8883
BOOTSTRAP_TENANT = “”
BOOTSTRAP_USERNAME = “”
BOOTSTRAP_CLIENT_ID = "“
PRODUCT_SERIAL_NO = ““

Internally userid = tanentId/bootsrapusername;

So by using above credential I am trying to do the request.

Once the request reach the Cumulocity and accept it. I will get the new details of user id and password for the connection.

I am trying since last few days.
But I have limited knowledge of REST so lagging in the coding part.

Can anyone help me on this?

Is it possible to writing in python?

Regards

Hello All,
After changing so many things on the code.
I am getting below error.

Error sending bootstrap request via REST API: 401 Client Error: Unauthorized for url

What mistake I am doing ?

Regards,

Hi @mhjarsania and welcome to the community,

I think to properly help you need to clarify a few things.

What is “our product”? A device? A system?
What did you mean with “registered on Cumulocity”?

So from what I understood: You are trying to register a device to Cumulocity and implement an agent that supports the bootstrapping process via REST?

Did you check this documentation?

In short you need to use the bootstrap credentials of your instance to send a POST to /devicecontrol/deviceCredentials with a body containing your id you used to register your device.

In the response you will get credentials which you should store locally.
In all other requests of the API you need to use the provided credentials to authenticate your requests.

It’s not a programming language question, but how you are implementing it.

In general: If you don’t provide code snippets, I don’t think the community can help you because it is not clear what your problem currently is.

The C8Y python api on github also contains a example how to do bootstrap with python:

2 Likes

Thank you both of you.
I will look into it and let you guys know.
Also I will try to see if I can share you the code soon.

Thank you all.
I am able to register my product over Cumulocity.

2 Likes