ajepe / odoo-addons

Odoo addons
24 stars 40 forks source link

Create Lead using REST API #6

Closed touqeershafi closed 5 years ago

touqeershafi commented 5 years ago

Hi there i'm creating lead from rest api using guzzle:

 $client = new GuzzleHttp\Client(['base_uri' => 'http://192.168.62.80:8069/api/']);
    $response = $client->request('POST', 'crm.lead', [
        'headers' => [
            'access-token' => 'access_token_21a3348987ae952ea2b13ec34b7fbdbaeb119f08'
        ],
        'form_params' => [
            'user_id' => 1,
            'name' => 'this is rest api lead',
            'type' => 1,
        ]
    ]);

On server side it's giving the following constraint error:

2018-12-17 13:41:13,393 4017 ERROR touqeer odoo.sql_db: bad query: b'INSERT INTO "crm_lead" ("id", "company_id", "date_last_stage_update", "stage_id", "probability", "color", "type", "date_open", "active", "team_id", "message_bounce", "priority", "user_id", "opt_out", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'crm_lead_id_seq\'), 1, \'2018-12-17 13:41:13\', 1, 10.0, 0, \'lead\', \'2018-12-17 13:41:13\', true, 1, 0, \'0\', 1, false, 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'
ERROR: null value in column "name" violates not-null constraint
DETAIL:  Failing row contains (35, null, null, t, null, null, null, 1, null, null, 2018-12-17 13:41:13.37546, 2018-12-17 13:41:13.37546, null, null, f, lead, 0, null, 1, 1, null, 2018-12-17 13:41:13, null, null, 2018-12-17 13:41:13, null, 0, 10, null, null, 0, null, null, null, null, null, null, null, null, null, null, 1, null, null, null, null, null, null, 1, 1).

Although i'm providing name paramter in the request.

ajepe commented 5 years ago

You are not suppose to get this error, I will try to simulate and get back to you