Skip to main content

Getting Started with REST API

Welcome to ServiceOps REST API. Our APIs allow third party systems to create, update, and read a request from our ServiceOps Platform.

All CRUD operations using APIs are done with the following methods: GETPOST, and DELETE.

To make requests to our system, first set up your client and authenticate to acquire an Access Token (Token ID).

Setting Up API Client

To begin making API requests, register your client with the ServiceOps system to obtain the necessary parameters:

  • Client ID
  • Client Secret
  • Username
  • Password

Login to the ServiceOps system, go to Admin > Automation > Integrations > Rest Integration, and register your product for REST API. For example: Here Postman is integrated with ServiceOps for using APIs.

Registration

After registration, you’ll need to authorize API access using one of two methods: generating an API key or obtaining an access token using the POST Get OAuth Token method.

OAuth 2.0 Authorization (Using Basic Auth Header)

For OAuth 2.0 authentication, an Access Token is generated by sending the Client ID and Client Secret using a Basic Authentication header, along with user credentials in the request body.

This method leverages the RFC 7617 standard for HTTP Basic authentication, where the Client ID and Client Secret are concatenated with a colon (:), Base64 encoded, and then sent in the Authorization header prefixed with Basic.

For example, if your ClientID is KnowledgeGraph-client and your ClientSecret is kGBjYDv75HyG7uN905HqG34:

  1. Concatenation: KnowledgeGraph-client:kGBjYDv75HyG7uN905HqG34
  2. Base64 Encoding: This string is then Base64 encoded to become S25vbGVkZ2VHcmFwaC1jbGllbnQ6a0dCallEdjc1SHlHN3VOOTA1SHE0MzQ=
  3. Final Header: The header in your request will appear as: Authorization: Basic S25vbGVkZ2VHcmFwaC1jbGllbnQ6a0dCallEdjc1SHlHN3VOOTA1SHE0MzQ=

This approach ensures a clear separation of concerns, with the application's identity (Client ID/Secret) authenticated via the header and the user's identity (username/password) provided in the request body.

POST Get OAuth Token

URL: http://{{server-url}}/api/oauth/token

Method: POST

Header:

KeyValue
AuthorizationBasic {ClientID:ClientSecret encoded in Base64} (See above for details)
content-typemultipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

Body

KeyDescription
usernameUsername of user (registered with our ServiceOps system) for whom API to be Executed.
passwordPassword of User (registered with our ServiceOps system) for whom API to be Executed.
grant_typeOAuth2 Grant Type. (i.e. password)

Example Request

curl --location 'http://172.16.11.148/api/oauth/token' \
--header 'Authorization: Basic UG9zdG1hbkludGVncmF0aW9uLWNsaWVudDpwMUZjM2xtUzlXclhiQmhPSXFkRA==' \
--header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
--form 'username="jerry@motadata.com"' \
--form 'password="admin@123"' \
--form 'grant_type="password"'

Example Response

{
"access_token": "eyJraWQiOiJmbG90by1rZXktaWQiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJqZXJyeUBtb3RhZGF0YS5jb20iLCJ1c2VyX25hbWUiOiJ1dWlkMzYtZTFkODIxYTgtMDQxNC00ZGU3LWFlNzQtNDA1NTQwNjI3ODRkIiwiaXNzIjoiaHR0cDovLzE3Mi4xNi4xMS4xNDgvYXBpIiwibG9naW5fc291cmNlIjoiTk9STUFMX0xPR0lOIiwiY2xpZW50X2lkIjoiUG9zdG1hbkludGVncmF0aW9uLWNsaWVudCIsImF1ZCI6IlBvc3RtYW5JbnRlZ3JhdGlvbi1jbGllbnQiLCJsb2dpbl9zc29faWQiOjAsIm5iZiI6MTc2NzE3NzY4MSwiZ3JhbnRfdHlwZSI6InBhc3N3b3JkIiwic2NvcGUiOlsib3RoZXItYXBpLXNjb3BlIl0sImV4cCI6MTc2NzM1MDQ4MSwibG9naW5fbXNwX3BvcnRhbF9pZCI6MCwiaWF0IjoxNzY3MTc3NjgxLCJqdGkiOiI4NGIwNTlkYi0wNmNkLTQzMGYtODFiYy1kODc1Njc3ZmU1YmQiLCJ0ZW5hbnRJZGVudGlmaWVyIjoiYXBvbG8ifQ.FxG9rYQ5FvENhlwBkjP14UhpCTMrqzxCYkWXzYrsg3glgzyEOYRo8gzqHzqKhY1sNWomefMMznIKci37DauEEFc1GYC_S3f2gX1toOJqaSwSPVrzjY3sDsAHJysl3QRlRGt4e5ALtYWMZpGKRg6bqG3VoI7SiQh5AJam0qTMhS-wLCG7bA4Phe6teKIBcR62nTRcm_HCA5lrM5L-XEyjFZUWrlQa53MNnDswHa9ZH5HtUqZDe-Szj-72KCQYVA7Yw0DvQKtn-gdvVcEUO_11hc42Z1M0kYO29Vp7QHbMsrlCDsWLO2gYnKPA2672_81RI-IXasKIpGzqGWvO5e1o7Q",
"scope": "other-api-scope",
"token_type": "Bearer",
"expires_in": 172798
}