In this app we are calling the POST /now/table/incidents
api that
Inserts one record in the incidents table according the passed in parameters.
- Visit Service Now developer and Sign Up.
- Sign In with your account after sign up.
- Click on
Request Instance
on the top-right corner of the screen. - select
orlando
and click on Request. - It will give you your instance URl with your username and password
- Visit that URL and change your password (Remember to note down your username and password as it will be required in the React Native App).
- As soon as you get into your instance .You will see a search bar in the left side with label
filter navigator
- Search for Tables in the filter navigator and select the
Tables
option under theSystem definition
Category - You will see a list of tables now Click on New to create a new table.
- Fill in the table label and Name will be filled automatically.
Note: This name will be used in future for API calls. So note the name, not the label - Go to the columns below and add a new column with column label
description
. This way you created a new table for your tickets. - Now You need to create a new application and connect this table with that application.
- Search for
Company application
in the filter navigator - Click on
Create New
to create a new company app. - Fill in the details like app name and description.
- In roles set admin only and continue ,
- select workspace and continue.
- In tables search for the table that you created earlier. Select it and continue then start the application.
- Click on continue until you get an option to open your app
- As soon as you get the open option Click on it and it will open your application in a new tab
- Clck on the list and here you will see a list of tickets for this specific app
- Create a .env file in the project directory and add the following variables Here is an example env file:
instance=yourinstance
username=Your_username
password=your_password
table_api_name=your_table
- Go to
index.js
and change the incident_description and fill the details of incidents(tickets):
const incident_details = {
'description': 'This is a dummy incident created with REST API'
}
Steps to start the Application:
Step1. Run npm install
to install all the dependency
Step2. Add .env
file with your config details as explained above.
Step3. Run node index.js
to start the application.
You can see the results in your console.
Steps to Test the Application:
Step1. Run npm run test-init
to initialise the test.
Step2. Run npm run test
to start the unit test.
Step3. Check the results in the console.
Note: If you get Timeout error for the test then you need to run the test again as it happens when the service now server doesn't responds properly.