send http request file through bot framework composer - botframework

I have web api in asp.net 5 and tried invoke using postman and it successed.
the simple way just wanna consume from bot framework composer. it has been difficult to understand how to send file image through http request post method. ${user.attachments} is variable that user input in bot.
when this scenario got error:
Object reference not set to an instance of an object
searching for several way it can be implemented using contentUrl but in fact it hidden can not be accessed. Is it possible implement that scenario? any suggest will appreciate.

the problem is that you need change de value to object.
{ "payload": {
"username": "${dialog.selectk.content[0].ticketid}",
"name": "${user.personalname}",
"favoritecolor": "${user.favcolor}",
"profileupdated": "${dialog.userprofileuptodate}" }}

Related

"Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request"

I finished this tutorial https://learn.microsoft.com/en-us/graph/tutorials/azure-functions?tutorial-step=5 everything worked fine until i published my azure Functions in my Azure App.
When i try to make the subscription i get this error "Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request". When i test with ngrok i can create the subscription with no problems but when i replace NgrokURL value for my Azure function Url, not. Is that the right way to create the susbcription? Also i tried to create the subscription in Graph Explorer but i still get this message.
As the same question raised in MSFT Docs Q&A Forum and thanks to the Shwetachoudhary provided the solution that helps other community members:
In the following below code,
content type must be text/plain.
body must include the validation token.
CodeSamples
asp .net mvc sample - Specifically look at the NotificationController.cs file
In the method
[HttpPost]
public async Task<ActionResult> Listen()
{
if (Request.QueryString["validationToken"] != null)
{
var token = Request.QueryString["validationToken"];
return Content(token, "plain/text");
}
'notificationUrl' must be able to respond to the request for validation. Make sure the validation token returns as plain/text as well. Refer to the Notification endpoint validation document provided by Microsoft.
Try isolating the code and calling the same API with Postman or Graph Explorer and see the results.

How to perform a GET request after a POST request with web-sockets

I am currently trying to build a go API using gin for a web and mobile application. I am new to the world of WebSockets and Go so I was wondering how I would go about triggering a GET request from the client after a relevant POST request was made ie: the POST request contained the user's ID so the clients who require information regarding that user are properly updated. Currently, I have the POST and GET requests which do what I need them, but I'm a little lost about how to make the entire flow realtime using WebSockets.
I believe this example of server-sent-events should address the question. Once a POST handler has been called, send a flag to the GET endpoint via a channel and then send an event through there.

Serverless Framework with lambda-proxy integation and API Model Validation

I have an issue validating a request with a model when the user changes the content-type of the request in a serverless framework lambda-proxy integration
As per AWS docs, we can not change too much when using lambda-proxy integration
For example, the passthrough behavior that explains what happens when a validation model does not match the request type, can not be used on lambda-proxy integration.
My problem: I want to reject all requests that are not JSON so they must be forced to use the model validation. But at the same time, I do not want to change the integration type from lambda-proxy to lambda.
What can I do to solve this issue?
BR
One thing you can do is inspect the headers in the event object to confirm that it is the type you expect and if not return an error:
https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html
We can enforce the Content-Type header straight into the API Gateway like below.
References can be found here: https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html

Laravel middleware cannot read posted data

Is it possible to read PUT, POST data in custom middleware?
This does not work:
$request->input('phone_number');
I'm trying to check posted data (check if customer_key or user_key is present) from a mobile app before reaching it to controller
As suggested by #skdroid, $request->phone_number works.
The problem for me was I was using POSTMAN and sending PUT request using form-data.
I switch it to raw with JSON and it works.

Upload image to Lambda using gateway API

I'm trying to let user upload pictures to a lambda function for processing; using the gateway API interface.
I tried to specify a model for my POST method, but so far I keep getting the error
Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
... Not so helpful.
I understand that I cannot directly send raw data to lambda and must using some kind of formatting in-between.
What I understood is that I could make the gateway interface base64 encode the data for me.
I tried to do so by using the following model schema with the content type image/jpeg
{
"body" : $util.base64Encode($input.body)
}
How to send the image ?
There is no native support in API Gateway for binary data as you have seen. We are working on this but I don't have an ETA for you. Some customers have had success base64 encoding the data like you have in your question, only it should be in a mapping template in the Integration Request not the Method Request.
If you set the content type to image/jpeg, then the encoding will apply only when the Content-Type header on the incoming request is also image/jpeg, so make sure to set that.
You can also reject incoming requests to the method that don't send the right Content Type by setting the 'Request body passthrough' (passthroughBehavior in the API) to the recommended value ("when there are no templates defined" or 'WHEN_NO_TEMPLATES' in the API)
Docs for the passthrough behavior -> https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#passthroughBehavior
Since it seems like working with binary data and API Gateway is complicated, I think you should:
Upload the image using API Gateway as an S3 proxy
Set a trigger for your lambda function on PUT for the bucket where you've uploaded the image

Resources