I’ve been working with the Service Node and have run into an issue where valid JSON sample responses are not accessible via the Context as expected. The steps I followed are (bot in offline mode serving sample data only):
Set up a Service Node with a GET request (using an OAuth v2 Authorization Profile I setup)
Add a Sample Response
This example is directly from the Microsoft Graph documentation (and service calls using Postman return in the same format). Here’s the link to the documentation article in case it’s helpful: https://docs.microsoft.com/en-us/graph/auth-v2-user
Trigger the Service Node via a task and observe
- You can see the GetUser Service Node has completed Service Execution and is printing the sample response as expected.
- The ParseGetUser Script Node performs the following script
print(JSON.stringify(context.GetUser));which shows the response is empty.
- In chat, the response displays as empty:
Adjust the sample response JSON
If I wrap the results of the sample JSON response in a “body” object, I can then access it through
context.GetUser. The problem with this is that I do not control the response from the Microsoft Graph API, so this needs to work with the sample I provided (shown above).
When attempting the same Service Node and task, the result shows. Based on this scenario, it looks like it searches for an enclosing key (in this case “body”) to populate the Context.
I have several questions to help me move forward.
- Does the Service Node depend on JSON responses enclosed in a “body” object?
- Am I missing something when setting up the Service Node that will allow me to work with the JSON variables from the service response?
Thank you in advance for your guidance and support. Please let me know if I can clarify anything in regard to this issue.