How to send input value in angular5 to grails3? - grails

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.

Related

Read request body in Angular2

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');

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.

Caching http responses in iOS

I'm starting an iOS app that consume a Restful API.
I have control over that API and I'm confusing with the caching policies.
To begin, I only need caching a concrete resoruce, but the problem is that resource can change when I insert new record in the database.
Then, how can I tell to the application "Hey! Make the request only if there have been changes and if not, you get the data from the cache!"
I'm using AFNetworking to make requests..
You'll have to make a decision on either server or client side and build your own protocol.
Example:
You could send the server JSON post request which contains the 'version' of the data you have in the app. On the server-side you will increment the version number each time the data gets refreshed. If the version number does not match at server-side, the server will respond with all new data, else the server responds JSON with 'up to date'
EDIT:
If you are looking for an HTTP response saying that the data is not modified. This is done on server side. You'll have to implement this in the server.

How do you create a web hook handler in Asp.net MVC 4?

My issue is that I do not know how to process an incoming request without knowing the URL that the post message is coming from.
The Vend API that I am trying to integrate with sends a post message to my URL with the following information:
"The POST body will include a field named payload. This field contains
a JSON encoded object with details of the object that caused the
hooked event. Other form fields (such as environment or domain_prefix)
may be present, but are not guaranteed to be.
The payload objects you’ll find in webhook requests are now the same
as those you’ll receive from the newer parts of the API marked as
version 1.0 or higher. So, for example, the product webhook should
give you a product payload that’s the same as if you requested
/api/1.0/product/{product_id}."
http://docs.vendhq.com/webhooks.html (here is the link for more details)
I'm fairly new to ASP MVC and I'm having trouble figuring out the best way to go forth. I need to eventually map the incoming name value pairs to my model.
Any help would be greatly appreciated.
When you said you don't know the URL that the post message is coming from, I think you mean that you don't know the format of the URL (path and parameters) that the webhook is being posted to. The only things your MVC app needs to know in order to process the request are the names of the post parameters, which in this case is a single parameter named payload that contains a JSON string according to the snippet you included from the documentation.
There are several ways for you to get this data. One of the most simple is to take advantage of ASP.NET MVC's automatic mapping of POST parameters to controller action method parameters:
public ActionResult MyActionMethod(string payload)
{
// 'payload' will be automatically populated with the json string from the POST payload
}
Of course you now have to parse the json payload which you can do in several ways using the .NET framework or with any number of 3rd party libraries.

Posting JSON data to Web API - where do I even start?

I have zero experience with Web API and JSON. My requirements are to create a service (I'm using Web API for this) that will accept MIME Encoded JSON data. The service will take that data, insert it into a database, and return the primary key value back to the client.
My hang-up is being able to know where to even start with this. A couple of questions that I have are:
When the device sends the JSON data, how will the service "accept" it? Meaning, what's being passed to the service isn't an URL that we commonly see with MVC (/Controller/Action/ID) which then invokes the Action Method. So, how will the service know what to invoke if I'm passing raw JSON data?
How would I test this if I don't have a device that sends the JSON data yet? Would I manually invoke an AJAX call and call that particular action method and pass in the JSON data that way?
I apologize for the seemingly elementary questions.
Thanks.
When you call a WebAPI-method you still have to specify the endpoint:
Example:
PUT /api/people
MVC knows from that that it should call the put-method on the PeopleController.
You can send raw JSON-data to test it. A good tool for that is HttpFiddler: http://fiddler2.com/
As for where to start, try to create a basic WebAPI-project with visual studio, it will include some samples and you can get going from that. If you run into wall, you can come back here

Resources