Unable to access Cumulocity API via Postman

Cumulocity IoT
Backend: 1011.0.12
UI: 1011.0.12

Are you using a free trial or a product with a customer license?

What are trying to achieve? Please describe in detail.

I want to set measurement or get measurements using API via Postman or Get some data.

Do you get any error messages? Please provide a full error message screenshot and log file.

Yes, I am getting an error response as seen in Screenshot_1,

I want to set measurement using REST API via Postman.
So I followed the ‘Postman’ topic mentioned on the following link,
cumulocity - guides - microservice-sdk/rest/

I followed each and every step to setup the environment(refer Screenshot_2) and then tried accessing the APIs. However I am stuck on the above error for all the APIs

Can anyone please list down the detailed steps to fire the APIs via Postman ? or Please let me know where I am going wrong.

Note - I had downloaded the postman collection from here,
cumulocity - guides/files/rest/Cumulocity_API.postman_collection.json

1 Like

Hi Prasad,

some things to check

  • Did you follow the documented guidelines to encode your credentials using Base64 and set them as the Basic Auth header?
  • The screenshot shows you calling tenant/loginOptions. Did you try a different endpoint? This endpoint actually does not require authentication
  • in the Administration Application go to Settings / Authentication. What is shown as the preferred authentication method?

Hi Harald,

  • I did follow the guidelines to encode my credentials using Base64 and have set them in the Auth Header.
  • I tried multiple end-points from the Postman collection like measurement/measurements, or {{url}}/s/(Register Templates). Please refer the screenshots below,

  • The preferred login mode is set to Basic Auth.

I have followed all the steps provided in the documentation but something is going wrong.

Let me know your thoughts on this, how I can proceed further ?

Hi Prasad,

I followed the steps in the documentation and it worked for me as expected. The error message you encounter means that you are sending credentials but they are not correct. Can you double check them?

I have a button in Postman on the right-hand side that allows me to display the code. Can you try that and see if in the code for a curl request the authorization header matches your expectations?

Best regards,
Harald

1 Like

Hi Prasad,

the error might occur because you are using the tenant id inside your url instead of the actual domain name. Can you double check this please.

Best regards
Christian

1 Like

Hi Harald,

Thanks for the update.

I tried checking the code part in Postman. But the auth header was as expected.
Then I got another reply from Christian and his solution worked for me.

Really thankful to you for answering my queries in such a short time !!! :slight_smile:

Hi Christian,

I tried with the actual domain name and it worked.
However as much as I remember the document mentions having a tenant-id inside the url.

But anyway, the issue was solved, thanks to you !! :slight_smile:

Hi Prasad, great to hear. The documentation only mentions to use the tenant id when naming the environment. For the URL it says “yourTenant” as an example, which can be a bit confusing. I’ll add feedback to the documentation team to make this a bit clearer.

FYI, when you are in the documentation, there is a small icon in the lower right-hand corner of your Browser. If you click on it you can report any errors or unclarity directly to the documentation team.

Best regards,
Harald

2 Likes

Hi Harald,

Thanks for the update.
I’ll surely use the ‘Feedback’ option as you mentioned.

Regards,
Prasad

Hi Prasad, I am facing the same problem but I don’t understand the solution can you please elaborate.

Hi Yousef, what URL are you using to do the request. Does it start with “t” followed by numbers?

https://env641673.us.cumulocity.com, env641673 is the tenant ID shown on the platform, I don’t know why it’s not starting with a t.

Do you also have a tenant name that you use to access the tenant from your Browser?

I’m not sure what do you mean by a tenant name but my username is the email I used to create the account which is yousef.okasha@techsa.io.

Hi Yousef, ok in your case tenant name and id are identical. What error message do you see exactly? Are you using “env641673/username” as the user name?


That is the error that I got.
and I’m using my email which is yousef.okasha@techsa.io as my username.

Can you try using env641673/yousef.okasha@techsa.io instead?


I’ve created a basic authorization using base64 as specified in the API documentation.
echo -n env641673/yousef.okasha@techsa.io:“PASSWORD” | base64. but still I got 401 status code.

Have you put BASIC before?

thats what we use. for example:

new user with username “API”
password: “api12345”

auth will be “Basic YXBpOmFwaTEyMzQ1” in that case

we use the decoder here:

baseurl in our case for postman is for example: https://t22xxxxxxx.iqtoly.cloud

Yes, you can see in the provided screenshot that is attached that I’ve put Basic before the authorization token.
I encoded this tenantID/username:password. for my case it is env641673/yousef.okasha@techsa.io:“PASSWORD”, isn’t that right?