node.js swagger x-ms-dynamic-value - node.js

I'm using swagger with node.js. I want to use x-ms-dynamic-values to return values to my parameter dynamically.
Basically the first parameter will have a URL then the node.js endpoint will make a get request to that URL and pull back lets say questions, Each URL can have a different amount of questions and the questions can also vary. The get request can get a json response with amount of questions on the page. In my next parameter I want to be able to select a question based on that response.
This is where the x-ms-dynamic-values will come in to play, But I'm nearly 100% sure there are no examples of this being used with node.js only thing I could find was c# example which i will link under this.
So basically my questions is, can anyone provide my with a little example of the node.js I may be able to work from ?
example of the swagger code :
"paths":{
"/api/contacts/{name}":{
"get":{
"tags":[
"DynamicSchemas"
],
"summary":"Get Contact Info",
"description":"Gets contact info of the specified type",
"operationId":"GetContactInfo",
"consumes":[
],
"produces":[
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters":[
{
"name":"name",
"in":"path",
"required":true,
"type":"string",
"x-ms-summary":"Contact Name"
},
{
"name":"contactType",
"in":"query",
"description":"Try either \"Phone\" or \"Email\"",
"required":true,
"type":"string",
"x-ms-summary":"Contact Type"
}
],
"responses":{
"200":{
"description":"OK",
"schema":{
"$ref":"#/definitions/ContactInfo"
}
},
"400":{
"description":"Invalid type specified"
},
"default":{
"description":"OK",
"schema":{
"$ref":"#/definitions/ContactInfo"
}
}
}
Api Example: https://github.com/nihaue/TRex/tree/master/Source

Related

Associated PXSelect/PXSelectReadOnly Returns Nothing on Sales Order Through OpenAPI

I've introduced a new DAC and a new field on the Sales Order associated to the new DAC key. When trying to retrieve the information through OpenAPI it comes back empty. I'd like to know why and how I can adjust my code to return the information. I've tried both PXSelect and PXSelectReadOnly
Declaring Statement on SOOrderEntry(extension):
public PXSelect<IOCSCompanyBrand, Where<IOCSCompanyBrand.companyBrandNbr,
Equal<Current<SOOrderExt.usrCompanyBrand>>>> CompanyBranding;
When I hit the URL: http://localhost/Acumatica21/entity/AcumaticaExtended21R1/20.200.001/SalesOrder?$select=OrderNbr,CompanyBranding,OrderType,CompanyBrand&$expand=CompanyBranding&$filter=OrderNbr%20eq%20'SO-030003'
This is the data that is returned:
[
{
"id": "f827cb43-9b8a-ec11-a481-747827c044c8",
"rowNumber": 1,
"note": {
"value": ""
},
"CompanyBrand": {
"value": "IO"
},
"CompanyBranding": null,
"OrderNbr": {
"value": "SO-030003"
},
"OrderType": {
"value": "SO"
},
"custom": {}
}
]
Acumatica Version: 21.205.0063
Here's the definition for SalesOrder in the endpoint (which was populated via the GUI)
I ended up opening a Acumatica Developer case and here is their response.
Hi Kyle,
Thanks for your time yesterday.
Endpoint mapping is valid but the fields in the view isn't fetch due the limitation of the filter parameter in the request. Filter parameter optimizes the data that are being fetch. In the case, the customer view isn't fetched. To workaround the limitation, instead of using filter, you can try something like below,
http://localhost/Acumatica/entity/AcumaticaExtended21R1/20.200.001/SalesOrder/SO/SO-030007?$expand=CompanyBranding
You can fetch the record and use expand to get the detail level fields. This way you can avoid the limitation of the filter.
Please check and let me know if you have any questions.
Regards,
Vignesh

How to search sharepoint file across document library

I'm trying to search files in SharePoint with GET https://graph.microsoft.com/v1.0/sites/root/drive/root/search(q='text file') but it searches only in the root site. Is there any way to search across the document library using graph API?
Something similar to POST https://graph.microsoft.com/v1.0/search/query. This endpoint searches files across the document library.
Is it possible to implement the POST api call behavior in the GET api call? Why because the response from POST api call doesn't provide information about file-mimeType, so I need to switch to GET api call.
You can specify the fields you want back in the response, as part of the fields sub-property. Specify mimeType.
To retrieve a custom property for a driveItem, query listItem instead.
POST https://graph.microsoft.com/v1.0/search/query
Request body
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "text file"
// filter by contentClass
//"queryString": "text file contentclass:STS_ListItem_DocumentLibrary"
},
"fields": [
"id",
"fileName",
"contentClass",
"createdDateTime",
"lastModifiedDateTime",
"webUrl",
"sharepointIds",
"createdBy",
"modifiedBy",
"parentReference",
"mimeType",
"fileType"
]
}
]
}
Specify select properties

Adding a mailbox filter to Gmail

I am trying to add a simple mailbox filter to Gmail, and getting error 400. The response text says that "Filter doesn't have any criteria" but of course I believe I do. Here is the payload data:
{
"filter": [{
"id": "ABC12345-2",
"criteria": {
"from": "donald trump"
},
"action": {
"addLabelIds": ["TRASH"]
}
}]
}
This is the URL that I am posting to:
https://gmail.googleapis.com/gmail/v1/users/{userId}/settings/filters
There is no problem with authentication. I have tried it with and without the "id" field. Any ideas about what I am doing wrong?
I'm not sure about your actual script. So I'm not sure about the requirement of {"filter": []}. But when I saw the official document, it seems that the sample request body for the endpoint of POST https://gmail.googleapis.com/gmail/v1/users/{userId}/settings/filters is as follows, when your request body is used.
Sample request body:
{
"id": "###",
"criteria": {"from": "###"},
"action": {"addLabelIds": ["TRASH"]}
}
id: string, The server assigned ID of the filter.
criteria: object (Criteria), Matching criteria for the filter.
action: object (Action), Action that the filter performs.
In this case, even when id is not used, no error occurs.
You can also test above at "Try this API".
References:
Method: users.settings.filters.create
Resource: Filter

Dialogflow Fulfillment URLnot sending any data

I am building a bot for google assistant. I have enabled fulfillment section for some intents. Dialog flow sends the request to the fulfillment url. The url is executed and a hard coded response is returned. I can see the response in the assistant simulator. Everything works fine except one thing. The request is empty.I can't access fields that are supposed to be present in the request.
I have accessed the same url using post request from a python code and it displays the parameters. So, there are no issues in the code. I think I am missing some configuration option.
I was expecting the post body in the following format:
POST body:
{
"responseId": "ea3d77e8-ae27-41a4-9e1d-174bd461b68c",
"session": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0",
"queryResult": {
"queryText": "user's original query to your agent",
"parameters": {
"param": "param value"
},
"allRequiredParamsPresent": true,
"fulfillmentText": "Text defined in Dialogflow's console for the intent that was matched",
"fulfillmentMessages": [
{
"text": {
"text": [
"Text defined in Dialogflow's console for the intent that was matched"
]
}
}
],
"outputContexts": [
{
"name": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0/contexts/generic",
"lifespanCount": 5,
"parameters": {
"param": "param value"
}
}
],
"intent": {
"name": "projects/your-agents-project-id/agent/intents/29bcd7f8-f717-4261-a8fd-2d3e451b8af8",
"displayName": "Matched Intent Name"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {},
"languageCode": "en"
},
"originalDetectIntentRequest": {}
}
But when I print the post data using print(request.POST), the actual post request shown is
One more thing: Does dialog flow append the action at the end of the fulfillment url? If so, I will have to handle the logic separately. I have done it without considering the action name. But a lot of my stuff is hacked, so I just want to be sure.
On another note, is dialogflow good enough? It has worked fine on a few examples similar to what it was trained on. How many training samples does it need to work properly? What is the underlying algorithm used in dialogflow? Or should I use the fulfillment url and handle everything on my own? I am inclined towards the later. I do not have too much faith in the existing chatbots.
Any help is appreciated.
If the Fallback Intent is the one being triggered, then you wouldn't get any parameters since this means that nothing else matched.
Got it. Used request.body. This solves the problem. Then parsed it using json.loads and accessed the parameters.

Time Series Insights - 'uniqueValues' aggregate not working as expected: does not return any data

I'm trying to execute some aggregate queries against data in TSI. For example:
{
"searchSpan": {
"from": "2018-08-25T00:00:00Z",
"to": "2019-01-01T00:00:00Z"
},
"top": {
"sort": [
{
"input": {
"builtInProperty": "$ts"
}
}
]
},
"aggregates": [
{
"dimension": {
"uniqueValues": {
"input": {
"builtInProperty": "$esn"
},
"take": 100
}
},
"measures": [
{
"count": {}
}
]
}
]
}
The above query, however, does not return any record, although there are many events stored in TSI for that specific searchSpan. Here is the response:
{
"warnings": [],
"events": []
}
The query is based on the examples in the documentation which can be found here and which is actually lacking crucial information for requirements and even some examples do not work...
Any help would be appreciated. Thanks!
#Vladislav,
I'm sorry to hear you're having issues. In reviewing your API call, I see two fixes that should help remedy this issue:
1) It looks like you're using our /events API with payload for /aggregates API. Notice the "events" in the response. Additionally, “top” will be redundant for /aggregates API as we don't support top-level limit clause for our /aggregates API.
2) We do not enforce "count" property to be present in limit clause (“take”, “top” or “sample”) and it looks like you did not specify it, so by default, the value was set to 0, that’s why the call is returning 0 events.
I would recommend that you use /aggregates API rather than /events, and that “count” is specified in the limit clause to ensure you get some data back.
Additionally, I'll note your feedback on documentation. We are ramping up a new hire on documentation now, so we hope to improve the quality soon.
I hope this helps!
Andrew

Resources