How to post MAF form data to Rest service in Json format? - hybrid-mobile-app

I have created a REST service which is working fine with GET method.
I want to post form data in JSON format with POST method. I have a ready form in MAF and a REST service which is working with GET.
How can I connect both using REST/JSON Service.

Convert your inputted data to your POJO object (the same you use to perform your GET) and then convert the POJO back to JSON and perform a POST.
An example can be found here: Please click this link.

Related

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.

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

Post attachment and additional form fields using Web API

I'm trying to create a form that allows the user to specify subject, body, attachment and post to an action using the web api and jquery. im not sure how to approach this.
any help would be greatly appreciated.
You could use use Json to hold the subject and body and then use the formdata to send the file. You can use $.ajax function to send the data data to server. You can then just parse the Json in the server code.

Send form data and generated pdf from orbeon to web service

Is it possible to setup Orbeon Forms to send data entered in form and pdf to another site or web service? I tried using workflow-send button as described in http://wiki.orbeon.com/forms/doc/developer-guide/configuration-properties/configuration-properties-form-runner#TOC-Workflow-send-button, but it in this case only xml data or pdf is send to success page.
Is there any other way to get data entered by user and generated PDF to another web application? I am new to this area, so it's possible that I missed something obvious in documentation.
You are right: when using the workflow send button and a POST or PUT, either a URL pointing to the PDF or the XML document is sent to the success or error page. However, the document id is also sent as the document request parameter. So I would:
Set the properties to have the PDF generated, so the PDF is sent in the POST or PUT.
In the target page, retrieve the PDF from the URL, and the XML from the persistence layer, using the document id provided to you in the document request parameter.
Sending the document as a request parameter was implemented after the 3.9 release, so you'll need to use Orbeon Forms 4.0 or newer (as of this writing you can use 4.0 M6).

Resources