can any one explain parsing JSON in REST API in layman?

NaveenKumaS
Kilo Contributor

can any one explain parsing JSON in REST API in layman?

 

 Provide me the most commonly asked interview questions on REST integration and Flow designer?

 

 

2 REPLIES 2

abirakundu23
Mega Sage

Hi @NaveenKumaS ,

1. JSON structure: We can send request body or Payload as a JSON format.
{
"u_anonymised_flag": "anonymized",
"u_application": "344",
"u_background": "Yes",
"u_candidate_target_start_date": "2023-10-16"
}
2. Parse JSON API: var parser = JSON.parse();
Use in REST API: Structure of the BR using Rest API 'POST' method

(function executeRule(current, previous /*null when async*/ ) {

// Request body
var req_body = {
"u_anonymised_flag": "anonymized",
"u_application": "344",
"u_background": "Yes",
"u_candidate_target_start_date": "2023-10-16"
};

try {


var r = new sn_ws. RESTMessageV2('Test', 'POST'); // 'Test' is Rest Message & using 'POST' method.

var response = r.execute();
var payload = JSON.parse(req_body);
var httpStatus = response.getStatusCode(); //receive response status code 
gs.info('SNOW response body: ' + JSON.stringify(payload));
gs.info('SNOW response status: ' + httpStatus);
}
catch (ex) {
var message = ex.message;
}
})(current, previous); 


Interview Question:
------------------------
1. Difference b/w SOAP & REST 
2.Uses of JSON.stringify() & JSON.parse()

3. Sometimes interviewer provide the payload in JSON format & how can we set the payload value in field of the table in ServiceNow.
4.Meaning of each HTTP status code

5. How many types of Authentications used in ServiceNow integration.

6. Scripted REST API

7. Have you worked on any Integration? Scenario based question based on integration.

Flow Designer
-------------------
1. Define Spoke, Action, Trigger

2. Flow API & Script
3. Scenario based as well
4. Difference b/w Flow & workflow

Please mark helpful & accept the answer if it's worthy for you.

 

 

 

 

abirakundu23
Mega Sage

Hi @NaveenKumaS ,

have you checked my previous reply?

If it's help for you, please mark helpful & accept answer.