Best Practices for Using Various API Styles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Our customer is currently designing a connection from a ServiceNow instance to API endpoints.
The request and response formats under consideration are as follows.
<Response Formats>
- JSON
- XML
- CSV
- INI format (*)
<Request Formats>
- GET with Query Parameters
- POST with Form Data
- POST with JSON Body
- Path Parameters
*Example of INI Format
- zipcode=1231234
- address=<Japanese address in Kanji>
- tel_no=0312345678
My Questions are;
1.
We understand that JSON and XML responses can be parsed using standard JavaScript capabilities provided by ServiceNow.
However, can ServiceNow also parse CSV and INI-style responses like the example above without additional implementation?
(Background: Our understanding is that libraries and modules that are typically available in a Node.js environment, including those imported using require(), cannot be utilized within ServiceNow.)
2.
Or would CSV and INI formats require custom parsing logic to be developed on the ServiceNow side?
3.
If custom processing is required, the customer currently appears to be using an API layer similar to a BFF (Backend for Frontend) that abstracts and normalizes response formats. In that case, would it be considered a best practice to place a BFF in front of ServiceNow and have it convert CSV or INI responses into JSON or XML before passing them to ServiceNow?
Alternatively, is there another recommended approach that would be preferable to using a BFF in this scenario?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @tomioyamash
I guess using new sn_impex.CSVParser() we will be able to parse CSV formatted response.
Read .CSV formatted files in ServiceNow
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Tanushree,
Thank you for your comments.
Certainly, the functions I was shown would likely be effective for specific formats like CSV.
However, the issue here is the existence of multiple API styles.
Given that context, we wanted to verify whether using a BFF aligns with ServiceNow best practices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @tomioyamash
Until now, all the integrations I have worked or have used a single API payload format.
From your use case, my understanding is that a single requirement may involve different API payload formats.
- If a single API request/response payload is expected to contain a mix of different payload formats, then my answer is that this is not feasible.
- If a requirement contains multiple integrations, where each integration uses a different API payload format, then I believe that is feasible to some extent. In that case, the response should also include the payload type.
For example, if the source instance (ServiceNow) receives an HTTP 200 OK response along with Payload Type = CSV, it can identify the payload format and parse it accordingly.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti