Forums

Covering OroCommerce, OroCRM, OroPlatform topics, including community updates and company announcements.

Forums Forums Oro Community Rest api – Response different Error

This topic contains 25 replies, has 2 voices, and was last updated by  Mike Kudelya 7 years, 5 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #24424

    Hi guys,

    While I was using Sandbox for querying account details, I am getting no contacts(child objects) related to the account despite related contacts are still there. I am using Community Portal and the request I am giving using the type:plain in api/doc. Help would be appreciated.

    Below is the response I am getting:

    “name”: “A. L. Price”,
    “createdAt”: “2016-08-31T08:26:51+00:00”,
    “updatedAt”: “2016-10-05T05:57:31+00:00”,
    “owner”: “gene.william_86ce0”,
    “contacts”: {},
    “defaultContact”: “Mr. Jerry Coleman”,
    “organization”: “CRMIT”,
    “referredBy”: null,
    “OpportunityDetails”: {}

Viewing 10 replies - 16 through 25 (of 25 total)
  • Author
    Replies
  • #24440

    Hi Mike, I am still getting this error.

    request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: “Invalid json message received “{“data”:{“type”: “contacts”,”attributes”: {“firstName”: “Contacts”,”lastName”:”Testing”},”relationships”: {“owner”: {“data”: {“type”: “users”,”id”: “1”}},”organization”: {“data”: {“type”: “organizations”,”id”: “1”}}}}}”” at C:\Apache24\htdocs\orocrm\vendor\friendsofsymfony\rest-bundle\FOS\RestBundle\EventListener\BodyListener.php line 122 {“exception”:”[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException: Invalid json message received \”{\”data\”:{\”type\”: \”contacts\”,\”attributes\”: {\”firstName\”: \”Contacts\”,\”lastName\”:\”Testing\”},\”relationships\”: {\”owner\”: {\”data\”: {\”type\”: \”users\”,\”id\”: \”1\”}},\”organization\”: {\”data\”: {\”type\”: \”organizations\”,\”id\”: \”1\”}}}}}\” at C:\\Apache24\\htdocs\\orocrm\\vendor\\friendsofsymfony\\rest-bundle\\FOS\\RestBundle\\EventListener\\BodyListener.php:122)”} []

    Can you let me know the functions getting called in a rest api?
    The content which I am sending is getting getting quotes(“) appended, how I don’t know..

    #24441

    Mike Kudelya
    Participant

    Hi

    If you are using PATCH, API calls patchAction https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/ApiBundle/Controller/RestApiController.php#L134

    I have tried decode your json to array, it is successfully decoded. As i understood you didn’t add first and last quotes to json in php code, right? Here before {: BadRequestHttpException: “Invalid json message received “{“data”

    If no, it is very strange, try to delete it.

    #24442

    Hi,

    Even I printed content in BodyListener.php, it is without quotes. Means the data which I am sending is correct, the quotes are added somewhere at the EventListener. Could you tell me at what files it is going to reach BodyListener.php and where it is returning, the whole flow while a request is made?

    #24443

    Mike Kudelya
    Participant

    Hi

    BodyListener.php calls when kernel.request event is called. Symfony documentation says the following:

    This event is dispatched very early in Symfony, before the controller is determined.

    This is a place where response is returning from controller.

    Do you still get ‘Invalid json message received’ error or not?

    #24444

    Hi,

    I am still getting the same error.
    What I did, I replaced

    throw new BadRequestHttpException(‘Invalid ‘.$format.’ message received”<.$content.>’);

    by

    throw new BadRequestHttpException($content);

    Still I am getting the below error in prod.log:

    request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: “”{“data”:{“type”: “contacts”,”attributes”: {“middleName”: “FSP”}}}”” at C:\Apache24\htdocs\orocrm\vendor\friendsofsymfony\rest-bundle\FOS\RestBundle\EventListener\BodyListener.php line 124 {“exception”:”[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException: \”{\”data\”:{\”type\”: \”contacts\”,\”attributes\”: {\”middleName\”: \”FSP\”}}}\” at C:\\Apache24\\htdocs\\orocrm\\vendor\\friendsofsymfony\\rest-bundle\\FOS\\RestBundle\\EventListener\\BodyListener.php:124)”} []

    You can notice that extra quotes(“) getting added before and after the content. Don’t know how it is happening?

    Can you help in this?

    #24445

    Mike Kudelya
    Participant

    I have tried wrap json to quotes in your client and have got the same exception message.
    I think there is two ways to resolve:

    – Tune your retrofit.
    – Remove quotes in $content variable before $decoder->decode($content);

    I’m almost sure that the symfony does not add these quotes, because BodyListener.php is executed before performing the controller.

    #24446

    Hi Mike,

    Its not working.

    #24447

    Mike Kudelya
    Participant

    Hi

    Try to debug the file, before $decoder->decode($content); call, $content variable must be valid.

    #24448

    Hi,

    How to debug that?

    #24449

    Mike Kudelya
    Participant

    Hi

    If in two words:

    – install xdebug extension for php
    – modify your php.ini
    – restart apache
    – configure your phpstorm
    – start debugging

    Here is an example how to configure.

Viewing 10 replies - 16 through 25 (of 25 total)

The forum ‘Oro Community’ is closed to new topics and replies.

Back to top