How to use Kentico 12 Rest API's using Postman.

Jahan Zeb asked on August 17, 2020 15:36

Hi,

I have a requirement to share a Kentico Rest API URL for external application. I am trying to use postman rest client to do so, but I am trying to follow the documentation is not helping at all, I have a very urgent requirement.

Please guide in this regard.

How url will be, and what headers will be use and how to authenticate the api or for with no authentication.

Regards,

Jahan

Recent Answers


Dmitry Bastron answered on August 17, 2020 17:35

Hi Jahan,

The REST API documentation is quite clear, to be honest. Please make sure you read the following articles:

After reading these articles do you have any more specific question of what is not working or not clear?

1 votesVote for this answer Mark as a Correct answer

Jahan Zeb answered on August 19, 2020 15:39

Dear Dmitry,

Thank you, I was missing admin's root directory while was trying to request the rest url.

Please guide in following scenario: - Shared one rest API with third party partner to share some data - created one new user for basic authentication - if I am not assigning global admin role, its returning forbidden 403. - I tried with Editor and Administrator roles but no luck. - I don't want that user to be logged into my system, only that user should fetch and share data with third party customer. - I am have a very big risk. I am still unable to find the solution using Kentico.

Looking for your kind and quick help.

Regards,

Jahan

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 19, 2020 18:38

This is strange. I've just created a user with "None" privilege level and was able to make a GET call with no problems, for example this request returned me a correct user XML:

http://localhost/Kentico12_1_Admin/rest/cms.user/administrator

Could you post you configuration of REST service (Settings > Integration > REST)? And please give me an example of your REST call. Then I will try to replicate your case more precisely.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 19, 2020 18:39

Another option is to use hash authentication if you don't want to share CMD user with third-party. But it will work with GET requests only.

0 votesVote for this answer Mark as a Correct answer

Jahan Zeb answered on August 20, 2020 08:32

Hi Dmitry,


Example URL:

- /cms/rest/cms.eventlog/all

REST Configuration:

- Service enabled: True
- Service enabled for: Objects
- Always check page security: False
- Page access is read only: False
- Object access is read only: False
- Allowed page types: Empty
- Allowed object types: cms.eventlog
- Default encoding: utf-8
- Allow sensitive fields for administrators: False

Regards,

0 votesVote for this answer Mark as a Correct answer

Jahan Zeb answered on August 20, 2020 08:34

With No Authentication:

  • 401 - Unauthorized: Access is denied due to invalid credentials.
0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 20, 2020 10:32

Thank you for the information provided, it makes much more sense now. Your configuration is correct, however, you would also need to do the following:

  • Create a new Role ("Rest client" for example) and add your user with "None" privilege level to this role
  • In the Permissions application, Permissions for: Module, Event Log grant Read to your role
  • And the last, please check the documentation on how you can query the objects

Documentation says:

Note: /all object retrieval requests only work if the user account used for authentication has the Global administrator privilege level.

Therefore, instead of /all you need to use some other data query parameter like TopN or Where to filter out the requested data. The following request, for example, will work:

http://localhost/Kentico12_1_Admin/rest/cms.eventlog?topn=100
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.