cancel
Showing results for 
Search instead for 
Did you mean: 

building api rest - insert register in table

building api rest - insert register in table

hi i have one problem whit my api rest, i am noob in this, i try do this 

Model/Hello.php

<?php
namespace Inchoo\Hello\Model;
use Inchoo\Hello\Api\HelloInterface;
 
class Hello implements HelloInterface
{
    /**
     * Returns greeting message to user
     *
     * @api
     * @param int $id Users id.
     * @param int $seller Users seller.
     * @param float $price Users price.
     * @param float $sprice Users sprice.
     * @return string Greeting message with users seller.
     */
    public function name($id, $seller, $price, $sprice) {
        
    
 
    $conexion = mysqli_connect($host,$user,$pass);
    mysqli_select_db($conexion,$db);
    $cprice=$price*1.15;
    mysqli_query($conexion, "INSERT INTO marketplace_product (entity_id, mageproduct_id, adminassign, seller_id, store_id, status, created_at, updated_at, wk_commission, wk_commission_price, wk_seller_price, wk_special_price)
    VALUES ('190', '$id', '0', '$seller', '0', '1', '2017-11-05 15:51:15', '2017-11-05 15:51:15', '0', '$cprice', '$price', '$sprice')");
   
    return "insertado";
  
    }
    
}

and my webapi.xml

<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
    <route url="/V1/hello/name/:id/:seller/:price/:sprice" method="GET">
        <service class="Inchoo\Hello\Api\HelloInterface" method="name"/>
        <resources>
            <resource ref="anonymous"/>
        </resources>
    </route>
</routes>

if i change GET by POST show me this: http://prntscr.com/hed6dq

 

if i put GET show me http://prntscr.com/hed7o0

and it don't save anythig

 

help pls