Read request body in Angular2 - post

I have a launcher site that launches different Angular2 apps I own (possibly on different domains) and want to pass in configuration details via a request body. Is it possible to send a POST request to an angular2 app so that I can send body data? And if so how do I implement a component? listener? router? to accept this data?

You can pass the data as query params of the application url and then use the angular2 router inside that application to extract the data.
See if this helps: https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters
sessionId = this.route.queryParams.map(params => params['session_id'] || 'None');

Related

Ask Twilio to pass custom headers in webhooks

I'm using Twilio REST Api to create a call programmatically, with call-status and recordings web-hooks wired in. The web-hook POST requests are currently hitting the server but failing on me because there is a requirement for a custom header entry.
I want to be able to pass my custom headers (that needs to be sent in the upcoming web-hook request headers) when I create those calls with the web-hook urls. The custom header should have dynamic value.
I have something like this:
call = #client.calls.create(
to: "+1XYZ",
from: ENV['TWILIO_ACCESS_NUMBER'],
twiml: '<Response><Record /></Response>',
status_callback: ##callStatusHandler,
status_callback_event: ['answered', 'completed'],
)
When I create such calls, I will have access to sessionid with a dynamic value, say my-session-value. Now when the webhook request comes in, I want sessionid = my-session-value in the header.
Is there a way to achieve this?
If you need to add your own custom headers, you can try to proxy your requests through some other logic before it hits your application servers. This was a past in the post around forking webhooks you can look at and see it it can be modified to meet your needs.
Creating A Twilio Function to trigger 2 webhook endpoints (Autopilot & FrontApp) For Incoming SMS
There is an example of passing a custom Axios HTTP header below:
Make a Write Request to an External API using urlencoded data

How to send input value in angular5 to grails3?

I can't find any tutorial in grails3 to get input value in textarea from angular5 or any frontend, because I want to comparing the value with my data in database
The angular app (client) would need to POST the data to the backend (server) grails part where your controller should handle the incoming request object and pass it around to any services, etc to do whatever it is you are trying to do. The angular side would need to be listening (i.e. subscribed to the post observable) for the answer from your grails app response and determine what to show the user.

Send a third-party API request when Case is created

I know in the "Settings > API Integration" I can add a URL that will receive a POST when a Case (Customer Inquiry) is created, however the contents of that POST only contains two IDs e.g. ObjectID=1234567&ObjectType=2001
Is there a way that I can send a custom POST to some URL with the actual form data? E.g. if I wanted to send the person who submitted the form a text message via a third-party SMS API
No; you'll need to respond to that POST with one that extracts the data you need from BC, then transform & forward that data to the SMS service.
This implies that you'll have a third server to handle those intermediary steps.
http://docs.businesscatalyst.com/reference/soap-apis-legacy/crm/case_retrieve.html
Another approach to do this is to write some ajax post function to post form data to the desired URL before submission.

Authorization when using plupload to upload images with Breeze

I'm using plupload in my Breeze/Durandal application to upload photos.
As part of configuring plupload in a given viewmodel, I set its url configuration property to point to an action on a Web API controller that is decorated with BreezeController and Authorize.
Examining the network trace in the browser developer tools, I see that the user's authorization info doesn't make it into the request. This actually makes sense, because the ajax isn't happening within breeze.
Any thoughts on how to properly secure this call to upload the image? I'd like access to the authenticated user id, otherwise I would have just let it be anonymous.
Thank you!
UPDATE: There's a headers option which allows you to set the request headers. Missed this when I was going through the documentation initially.
Are you just trying to tunnel an AJAX request through Breeze? This can be done using the Breeze.AjaxPost.js adapter.
http://www.breezejs.com/documentation/breezeajaxpostjs
This would be used similar to a query except that you would attach a payload somehow -
var payload = JSON.stringify(payload);
// Query to post your payload
var query = breeze.EntityQuery
.from('api/postsomething')
.withParameters({
$method: 'POST',
$encoding: 'JSON',
$data: payload
});
return manager.executeQuery(query).then(saveSucceeded).fail(saveFailed);
}
Now, this example is stringifying some JSON to post to the server, how you would do this with an image is beyond me but this should hopefully get you started.
In fact, I forgot about this answer which should provide some extra resources if you need them - breeze 1.4.8 & angular ajax adapter: how to customize ajax settings?
There's a headers option which allows you to set the request headers. Missed this when I was going through the documentation initially.

Javafx webview http response data

Is it possible to read the http request and response data from pages loading inside webview. What i want to do is get the binary data from a response after user clicks on a link inside the page in webview. Any help or clue would be greatly appreciated
Create your own URLStreamHandlerFactory initialized by URL.setURLStreamHandlerFactory which generates a URLStreamHandler that wraps the standard http and https URLStreamHandlers to intercept their traffic before forwarding.
Some of the concepts are explained in A New Era for Java Protocol Handlers whitepaper.
Another option is to listen to the WebEngine.location property and open a separate connection to a server to retrieve and process the binary data as needed. An example of this approach is the pdf handling code for the willow web browser.

Resources