how to do web service post?

0

To make a web service ( post ) I have to send the data that you enter in a form that will show you send it by post but I do not know how to do it. I had an idea but it did not work for me. Thanks in advance.

This is what I have to send by post

POST (here's a URL)

BODY

 {"client_data":{"id_doc":"",
                 "first_name":"",
                 "last_name":"",
                 "email":"",
                 "phone":""},
   "title":"PROSPECTO DE ALIADO",
   "type":"REQUEST",
   "weight":1,
   "channel":"WEB",
   "description_markdown":"",
    "time_estimate":1728000,}

this is the form

<input type="text" id="nombres" required>

<label for="apellidos">Apellidos </label>
<input type="text" id="apellidos">

<label for="cedula">Cedula / RIF*</label>
<input type="text" id="cedula" required >

<label for="telefono">Telefono / Celular</label>
<input type="text" id="telefono">

<label for="email">Correo electronico </label>
<input type="text" id="email">

<label for="descripcion">Asunto </label>
<textarea id="descripcion"></textarea>
    
asked by Daniel Martinez 09.08.2018 в 20:27
source

1 answer

1

In what language have you developed your system? And as an observation all your inputs must have the property 'name'

<input type="text" id="nombres" name ="nombres" required>

So that the service interprets the values that you are sending and in some way they must be equal to those that the JSON asks you ("Body").

To perform APIs so that you can consume the information through POST or GET, you can use SLIM Framwework

Assuming that you will mount everything in localhost with a subdirectory "myapp" is an example of how to create a service in post and your access url would be the following link

$app->post('/api/users', function ($request, $response) { //este lo defines como tu quieras
  $input = $request->getParsedBody(); 
  print_r($input); //basicamente aqui llegan todo tu post del formulario
});
    
answered by 09.08.2018 / 21:13
source