- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 08:45 PM
Hi Community,
Below is the http method where default content is set. However when I'm invoking this http method from script & passing dynamic entity Name, the results are showing as per the values set in the content, not as per the dynamic values passed.
Script:-
Could someone please help with the script to override the content defined in http method?
Thanks,
Ankita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 01:52 AM
var requestBody = '{"entityName": "' + search_term + '", "maxRecordsToReturn": 10}';
var request = new sn_ws.RESTMessageV2('global.sentinel', 'GetSearchEntity');
request.setRequestBody(requestBody);
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var errorMsg = response.getErrorMessage();
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Samiksha Gunjate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 10:44 PM
Hi @Ankita Kolhe ,
are you trying to set the request body? See the example below:
var requestBody = {};
requestBody.key1 = value1;
requestBody.key2 = value2;
request.setRequestBody(JSON.stringify(requestBody));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:25 PM
Hi @Ankita Kolhe,
Here's an example of how you can adjust your script:
var request = new sn_ws.RESTMessageV2('global.sentinel', 'GetSearchEntity');
request.setStringParameterNoEscape('entityName', search_term);
request.setStringParameterNoEscape('maxRecordsToReturn', '10'); // Ensure that maxRecordsToReturn is also set properly
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var errorMsg = response.getErrorMessage();
// Process the response as needed
Please hit helpful and accept this as a solution if it solved your problem.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 01:52 AM
var requestBody = '{"entityName": "' + search_term + '", "maxRecordsToReturn": 10}';
var request = new sn_ws.RESTMessageV2('global.sentinel', 'GetSearchEntity');
request.setRequestBody(requestBody);
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var errorMsg = response.getErrorMessage();
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Samiksha Gunjate