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, 4 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 15 replies - 1 through 15 (of 25 total)
  • Author
    Replies
  • #24425

    Mike Kudelya
    Participant

    Hi,

    What version of oro are you using ? I have tried your case on 1.10.6, sandbox returned me contacts. Does orocrm_account_to_contact contain relations ? My Account edit page, api response.

    #24426

    I am using this endPointURL : api/rest/latest/accounts and how can I use filter and sort while querying?

    #24427

    And I am not able to get a response when using this endPointURL : localhost/api/accounts?filter[id]=12 from my Java Code, I am using retrofit library??

    #24428

    And I am not able to get a response when using this endPointURL : localhost/api/accounts?filter[id]=12 from my Java Code, I am using retrofit library??

    #24429

    Mike Kudelya
    Participant

    When you are trying localhost/api/accounts url, does it return any response ?
    Try to get response via curl, here i described how you can do it.

    #24430

    Thanks Mike Kudelya for help on this topic.

    Can I get some resources on how to do Patch and Post operations in Java for Rest Api calls in ORO Crm?
    I am using retrofit jar and both Patch as well as Post method is working fine in the sandbox but when I am trying to do the same in Java it’s throwing Bad Request Error. Steps I am following to carry out the Patch/ Post method on ORO Entity..

    1. Generating X-WSSE authorization.
    2. Setting Content-Type as “application/vnd.api+json”.
    3. Sending the Body part as String.
    4. The target endPoint URL is like localhost/api/{entity}.

    Please refer below for the Patch method I am trying to execute:


    RequestBody requestBody = RequestBody.create(MediaType.parse(“application/vnd.api+json”), msg);
    Call<List<OroClient.OroContacts>> call = client.updateContact(id, requestBody);


    @Headers({
    “Accept: application/vnd.api+json”,
    “Content-Type: application/vnd.api+json”
    })
    @PATCH(“api/contacts/{id}?format=json”)
    Call<List<OroContacts>> updateContact(@Path(“id”) String id, @Body RequestBody requestBody);

    msg is the string variable containing the Body part. Its like:

    {“data”:{“type”:”contacts”,”id”:”3″,”attributes”:{“middleName”:”FSP”}}}

    Id id the id of the contact I have to update.

    Please note the same is working fine in api/doc as well as in the Rest Client.

    #24431

    Mike Kudelya
    Participant

    Hi

    I am not familiar with java and android, but as i understood when you got ‘Bad Request’, api call hasn’t been done, request is forming before call. I think you should check our configuration of retrofit. Correct me if i’m wrong.

    I would like to say that if you want to determine any errors on oro side you should look at oro logs (/app/logs) If there won’t success i suggest you install xdebug and check patchAction. Also i can deep inside $processor->process(..)

    #24432

    Hi

    From where I can go through the configuration of retrofit done for ORO?

    #24433

    Hi,

    I went through the app/logs and I am getting this error message: Invalid json message received
    What’s wrong with my json message?

    #24434

    Mike Kudelya
    Participant

    Replace 119 line of /vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/BodyListener.php and set:

    instead:

    Please show me full exception message with $content variable.

    #24435

    The message for $content is :

    Invalid json message received <\”{\\\”data\\\”:{\\\”type\\\”:\\\”contacts\\\”,\\\”id\\\”:\\\”3\\\”,\\\”attributes\\\”:{\\\”middleName\\\”:\\\”FSP\\\”}}}\”>

    #24436

    One more thing Mike, do we need to send JsonArray or JsonObject?

    #24437

    Mike Kudelya
    Participant

    When i print $content variable

    result is:

    content: <{“data”:{“type”:”contacts”,”id”:”1″,”attributes”:{“middleName”:”FSP3″}}}>

    maybe in your json contains extra slash \
    try to remove it before $decoder->decode($content); call:

    #24438

    Mike Kudelya
    Participant

    One more thing Mike, do we need to send JsonArray or JsonObject?

    In my case it is object

    #24439

    Thanks Mike, I will just check whether it is working or not and let you know ASAP?

    By the way, at what time slot you are able to go through these queries?

Viewing 15 replies - 1 through 15 (of 25 total)

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

Back to top