ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 3 replies, has 2 voices, and was last updated by  cardiac 2 years, 2 months ago.

  • Creator
    Topic
  • #11345

    cardiac
    Participant

    Hi all,

    I have the same problem, some of the other users have.

    OroPlatform: 1.7.0

    Guzzle Request:
    $response = $this->client->post(
    'http://crm-dev.dev/api/rest/latest/leads.json',
    [
    "headers" => [
    "Authorization" => "WSSE profile="UsernameToken""
    "X-WSSE" => "UsernameToken Username="bolt", PasswordDigest="1ePa3pK+CQiurS/J3HyZawJmbWA=", Nonce="559b83c9cf4fb", Created="2015-07-07T09:46:17+02:00""
    ]
    "json" => [
    "gender" => "male"
    "firstname" => "Test"
    "lastname" => "Test"
    "email" => "test@test.de"
    "phone" => "0170 123 123"
    "zipcode" => "81541"
    "city" => "Weilheim"
    "source" => "bolt"
    "sourceId" => "4"
    ]
    "debug" => "debug"]
    );

    Response:
    {"code":400,"message":"Validation Failed","errors":{"children":{"gender":{"errors":["This value should not be blank."]},"firstName":{"errors":["This value should not be blank."]},"lastName":{"errors":["This value should not be blank."]},"phoneNumber":[],"email":{"errors":["This value should not be blank."]},"address":{"children":{"id":[],"label":[],"namePrefix":[],"firstName":[],"middleName":[],"lastName":[],"nameSuffix":[],"organization":[],"country":[],"street":[],"street2":[],"city":[],"region":[],"region_text":[],"postalCode":[]}},"organization":[],"bankFirstName":[],"bankLastName":[],"bankIban":[],"sourceId":[],"source":[],"bankBic":[]}}}

    Debugging:
    AppBundle\Form\Handler\LeadHandler.php
    echo 'Form Name: ' . print_r($this->form->getName(), true) . PHP_EOL;
    echo 'Keys: ' . print_r(array_keys($this->form->all()), true) . PHP_EOL;
    echo 'Values: ' . print_r($this->request->request->all(), true) . PHP_EOL;
    echo 'Method: ' . $this->request->getMethod() . PHP_EOL;
    die('FALSE!' .print_r($this->form->getErrors(), true));
    die();

    Form Name: lead
    Keys: Array
    (
    [0] => gender
    [1] => firstName
    [2] => lastName
    [3] => phoneNumber
    [4] => email
    [5] => address
    [6] => organization
    [7] => bankFirstName
    [8] => bankLastName
    [9] => bankIban
    [10] => sourceId
    [11] => source
    [12] => bankBic
    )

    Values: Array
    (
    [gender] => male
    [firstname] => Test
    [lastname] => Test
    [email] => test@sb.banovo.de
    [phone] => 0170 123 123
    [zipcode] => 81541
    [city] => Weilheim
    [source] => bolt
    [sourceId] => 4
    )

    Method: POST
    FALSE!Array
    (
    )

    But $entity is empty, because func_get_args() is empty in RestController.php#L55

    Hope somebody of you can help me out fixing this problem.

    Thanks and regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #11349

    cardiac
    Participant

    Got it.

    The array is:


    "json" => [
    "lead" => [
    "gender" => "male",
    "firstname" => "Test",
    "lastname" => "Test",
    "email" => "test@test.de",
    "phone" => "0170 123 123",
    "source" => "bolt",
    "sourceId" => "4",
    "address" => [
    "zipcode" => "81541",
    "city" => "Weilheim",
    ]
    ]
    ];

    #11351

    Vova Soroka
    Oro Core

    Yes, lead fields should be wrapped in “lead” array.
    I’ve tried the following on the latest master and it works fine.

    $this->client = new \Guzzle\Http\Client();
    $request = $this->client->post(
    'http://oroent.dev/app_dev.php/api/rest/latest/leads.json',
    [
    'Content-Type' => 'application/json',
    'Authorization' => 'WSSE profile="UsernameToken"',
    'X-WSSE' => '...'
    ],
    [
    'lead' => [
    'name' => 'Test Lead',
    'namePrefix' => null,
    'firstName' => 'First',
    'middleName' => null,
    'lastName' => 'Last',
    'nameSuffix' => null,
    'jobTitle' => null,
    'phoneNumber' => '517-782-7343',
    'email' => 'test@test.com',
    'companyName' => 'Test Company',
    'website' => null,
    'numberOfEmployees' => 10,
    'industry' => null,
    'notes' => null,
    'contact' => null,
    'owner' => 1,
    'customer' => null,
    'dataChannel' => 1,
    'campaign' => 5,
    'source' => 'website'
    ]
    ],
    ['debug' => 'debug']
    );
    $response = $request->send();

    #11842

    cardiac
    Participant

    Thank you Vova Soroka for your reply!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.