Which AMP extensions can fetch a response from an endpoint? - cross-domain

What AMP extensions can be used to get a response from the server in the form of variable that can be used later, such as in a template or as a parameter to an attribute?

amp-access
The authorization endpoint of amp-access can return "a free-form JSON object":
Here’s a small list of possible ideas for properties that can be returned from the Authorization endpoint:
Metering info: maximum allowed number of views and current number of views.
Whether the Reader is logged in or a subscriber.
A more detailed type of the subscription: basic, premium
Geo: country, region, custom publication region
amp-form
amp-form "allows publishers to render the responses using Extended Templates". The response is expected to be a valid JSON Object. Try the "Hiding input fields after success" demo in the amp-form sample to see it in action.
amp-list
amp-list fetches "content dynamically from a CORS JSON endpoint and renders it using a supplied template". The response must be a JSON object that contains an array property "items".
In addition to {{variable}} substitutions in Mustache templates, you can also use AUTHDATA(variable) elsewhere.
amp-live-list (not quite)
amp-live-list is a "wrapper and minimal UI for content that updates live in the client instance as new content is available in the source document". The page will re-fetch itself, giving the server a change to send new content. If new content is found, AMP will populate a <div items> element with the new (HTML) items. You can't use that as a variable.

It's name doesn't really suggest it, but I think you want AMP-list
https://github.com/ampproject/amphtml/blob/master/extensions/amp-list/amp-list.md
Fetches content dynamically from a CORS JSON endpoint and renders it using a supplied template.

Related

How to pass a document's ID using Azure CosmoDB?

I am creating a simple CRUD app to learn Azure. I have created a logic app (standard model) and my APIs are designed using the workflow designer. I also have a CosmoDB to hold each object.
My GET API, that gets all the documents, looks like this:
And my GET API, that gets only one document, looks like this:
Here is what my CosmosDB looks like with the ID of the item that is successfully return when statically called:
So what do I need to replace the static ID with, in the *Document ID input so that I can pass in different IDs?
I have looked at the docs and it suggests documentId, but when I type this in I get this error:
Thanks!
Thank you #404 , posting your suggestion as an answer to help other community members.
" You should know the id you want to retrieve from the flow that feeds into the Get a document block (unless it's static). Since you only have a HTTP trigger your id should be supplied through that. As example by passing the id in the url as query parameter which you then refer to in your Document ID field."
Trigger a post request to logic app with Document ID in request body.
Try as below:

How do you call a 3rd party API from inside watson assistant?

Creating a chatbot using IBM's Watson Assistant, and I need to make a determination I'm trying to send the zip code to a third party API that will return the city and state so I know where the client is located so I can (a) know which services are available and (b) have a better idea on how to direct the conversation from there. But I am at a loss as to how to do this.
I can do this from within Python, but trying to code it in a JSON editor doesn't work.
Webhooks are used to do this from inside the Dialog skill in an Assistant.
IBM Watson Assistant webhooks documentation
The docs do not mention it, but the Assistant will POST to the URL with a JSON body containing the parameters you specify as key value pairs. For example if in the Dialog Node the context variable $zipcode equals '99501' and you specify the parameters "key" = zipcode and "value" = "$zipcode".
Then the HTTP post body is
{ "zipcode" : "99501" }
The response from the service is put into another context variable, and this can then be used for other things. For example in the Dialog Node which calls the webhook, in the "Return variable" section put webhook_result_zipcode to put the response into that context variable.
You can also in the dialog node Assistant responds section, return a message which contains some part of the webhook response. For example in the Dialog Node editor
"If assistant recognizes" $webhook_result_zipcode "Respond with" The code is "$webhook_result_zipcode.response.result.sent" This will tell the user the code which is returned deep within the webhook response in response.result.sent in the response body.
You can also click the Cog next to the response, and in the dialog, click ... next to "Assistant responds" and open the context editor. This opens a context editor (at the top of the dialog) which allows setting of another context variable from part of the webhook response. For example under "Then set context" for "Variable" set zipcode and for "Value" set "$webhook_result_zipcode.response.result.sent.zipcode". This will extract a zipcode value from deep within the webhook response and place it in the context variable zipcode.
Of course then you must find a zipcode location service which accepts a HTTP post and looks for the code in the body.

Acumatica REST API - StockItem - how to expand Price Item in request

I am using the Acumatica REST endpoint https://sandbox.kimballinc.com/AcumaticaERP/entity/Default/6.00.001 in my application
I am using the URL https://sandbox.kimballinc.com/AcumaticaERP/entity/Default/6.00.001/StockItem?$filter=InventoryID eq '123456'&$expand=WarehouseDetails to fetch info about a Product and to get complete warehouse details
My query is how to expand and get Price/CostInfo details in the response
Expand should be used for the arrays declared inside the entity in the web service endpoint:
Price/CostInfo is not an array so it can't be expanded. The default endpoint doesn't contain those fields so you'll need to extend the endpoint and add them:
Select the StockItem entity and use POPULATE button to add the fields:
Extended endpoint requires that you specify a different endpoint name:
In this example I choose DefaultPlus so I need to connect to:
https://xyz/AcumaticaERP/entity/DefaultPlus/6.00.001/StockItem
Instead of:
https://xyz/AcumaticaERP/entity/Default/6.00.001/StockItem
The added fields will be part of the GET response for StockItem, no special parameter is required for that.
I took a look at your site and noticed that you are using Acumatica 2018 R2.
I would then recommend that you use the latest version of the endpoint 18.200.001 as there are more field there by default.
If I saw correctly some of the fields for the Price/Cost Info are already in the main entity as they have a relation 1:1 to it.
To resume it using the latest version of the endpoint would allow you to see these field without the need to expand anything.

Updating a wiki page with the REST API

How do you update a SharePoint 2013 wiki page using the REST API?
Three permutations:
Reading an existing page (content only)
Updating an existing page
Creating a new page
For reading an existing page, of course I can just to a "GET" of the correct URL, but this also brings down all the various decorations around the actual data on the wiki page-- rather than fish that out myself, it would be better if there was a way to just get the content if that is possible.
Are there special endpoints is the REST API that allow for any of these three operations on wiki pages?
As stated in GMasucci's post, there does not appear to be a clean or obvious way of instantiating pages through the REST API.
You can call the AddWikiPage method from the SOAP service at http://[site]/_vti_bin/Lists.asmx. This is an out of the box service that will be accessible unless it has been specifically locked down for whatever reason.
To read the content of a wiki page through the REST API, you can use the following endpoint:
https://[siteurl]/_vti_bin/client.svc/Web/GetFileByServerRelativeUrl('/page/to/wikipage.aspx')/ListItemAllFields
The content is contained within the WikiContent field. You may want to add a select to that URL and return it as JSON to reduce the amount of data getting passed over if that is a concern.
As for updating the content of an existing wiki page, it is not something I have tried but I would imagine it's just like populating another field through the REST API. This is how I would expect to do it:
Do a HTTP POST to the same endpoint as above
Use the following HTTP headers:
Cookie = "yourauthcookie"
Content-Type = "application/json;odata=verbose"
X-RequestDigest = "yourformdigest"
X-HTTP-Method, "MERGE"
If-Match = "etag value from entry node, returned from a GET to the above endpoint"
Post the following JSON body
{
"__metadata": { "type": "SP.Data.SitePagesItem" },
"WikiField" : "HTML entity coded wiki content goes here"
}
The interim answer I have found is to not utilise REST, as it appears to not be
fully documented
fully featured
supported across Sharepoint 2013 and On-line in the same way
So my current recommendation would be to utilise the SOAP services to achieve the same, as these are more documented and easily accessible.

How to provide information in the html link for Facebook open graph api call of "property name" when posting trying to post an action

I am trying to create an html object dynamically with the necessary header information depending on the query string in the link I provide to Facebook. I am hoping that Facebook open graph will call this html link as I provided. However it seems that query string info are not getting passed to my server. Do anyone know how to make this work or what is the more appropriate way to do this. BTW, I am writing my code in Node.js.
To get more info about Facebook open graph api, look here, https://developers.facebook.com/docs/beta/opengraph/actions/.
For example, the link I am trying to pass to Facebook is, "http://xxx-url.com/getFacebookObject?objectId=&description=first dynamic post", so I sent a request with the link as, "https://graph.facebook.com/me/app-name:action-name?object=http://xxx-url.com/getFacebookObject?objectId=&description=first dynamic post". However, when I check the log on the server, I don't see anything in the query string.
Instead of using the query string, you can embed the data in the URL:
http://some-domain.com/getFacebookObject/id/description
Then, depending on what node.js packages you're using, extract the data from the request:
// expess.js style
app.get("/getFacebookObject/:id/:description", function(req, res) {
var id = req.params.id,
desc = req.params.description;
// your code...
});
(See http://expressjs.com/guide.html.)
Sorry, Facebook will strip off all query string information from the URL when they launch your site in the iframe. If it was a page tab app, then you could add it to the app_data query string parameters which in turn gets passed to your iframe's page tab app via the app_data part of the signed_request parameter.

Resources