Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'firstName' filter is not supported in OroCRM Rest JSON API #306

Closed
pedrofurtado opened this issue Apr 23, 2018 · 18 comments
Closed

'firstName' filter is not supported in OroCRM Rest JSON API #306

pedrofurtado opened this issue Apr 23, 2018 · 18 comments
Labels

Comments

@pedrofurtado
Copy link
Contributor

pedrofurtado commented Apr 23, 2018

When I tested the Oro API in /api/doc/rest_json_api#get--api-contacts I've tried two filters. The first worked well, that is the field 'lastName' (See the image below):

certo

But when I change the filter to be 'firstName' (that Oro has a default field from installation), the endpoint not works, giving me an unexpected error (See the image below):

erro

How do I, through the Oro REST API, select all contacts filtering by 'firstName'? Is this a bug?

Thanks!

@anyt
Copy link
Contributor

anyt commented Apr 23, 2018

What version of oro platform do you use?

@pedrofurtado
Copy link
Contributor Author

@anyt 2.6.1

@pedrofurtado
Copy link
Contributor Author

pedrofurtado commented Apr 23, 2018

@anyt I've tested it in a fresh application of OroCRM, without any custom bundle.

@pedrofurtado
Copy link
Contributor Author

pedrofurtado commented Apr 23, 2018

@anyt This error also appears in Oro demo (https://demo.orocrm.com/desktop/api/doc/rest_json_api). Try to use the 'firstName' filter to see the error.

erro-demo

@pedrofurtado pedrofurtado changed the title 'firstName' filter is not supported in OroCRM API 'firstName' filter is not supported in OroCRM Rest API Apr 23, 2018
@pedrofurtado pedrofurtado changed the title 'firstName' filter is not supported in OroCRM Rest API 'firstName' filter is not supported in OroCRM Rest Json API Apr 23, 2018
@pedrofurtado pedrofurtado changed the title 'firstName' filter is not supported in OroCRM Rest Json API 'firstName' filter is not supported in OroCRM Rest JSON API Apr 23, 2018
@anyt
Copy link
Contributor

anyt commented Apr 23, 2018

There is documentation in first tab of every methods, and there is no firstName filter described.

But it's strange that this filter was not enabled by default I don't see any configuration responsible for that, let me check.

@pedrofurtado
Copy link
Contributor Author

pedrofurtado commented Apr 23, 2018

@anyt Notify us if you have any news about this, or some workaround until the final solution.

@vsoroka
Copy link
Contributor

vsoroka commented Apr 23, 2018

Hello @pedrofurtado,
by default the filtering is enabled only for fields which have the database index. It is made by performance reasons.
To enable filtering for "firstName" field you can add DB index for it or enable it in api.yml if you sure that it is safe for your application.

@anyt anyt added the question label Apr 24, 2018
@pedrofurtado
Copy link
Contributor Author

pedrofurtado commented Apr 24, 2018

@vsoroka Could you give me an example code of api.yml that enables 'firstName' as a filter in Oro JSON API? Because I don't know in which folder I have to create this file, and neither what content it should have to works.

@anyt
Copy link
Contributor

anyt commented Apr 24, 2018

File should be created at Resources/config/oro directory of your bundle

@anyt
Copy link
Contributor

anyt commented Apr 24, 2018

It's described at the beginning of documentation that @vsoroka mentioned before
https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/ApiBundle/Resources/doc/configuration.md#overview

@pedrofurtado
Copy link
Contributor Author

@anyt @vsoroka After create this file, I need to execute some command in console to make it works? And I can make it works in a already created Oro Application, right?

@anyt
Copy link
Contributor

anyt commented Apr 24, 2018

Yes, you should run the command.

Forth paragraph form the above doc:

Important:
Run the oro:api:cache:clear CLI command to immediately make an entity accessible via the data API. If you use the API sandbox, run the oro:api:doc:cache:clear CLI command to apply the changes for it.

@pedrofurtado
Copy link
Contributor Author

@anyt Thank you! I will try to package this issue into a new bundle. I will feedback you later about this. Thanks again!

@pedrofurtado
Copy link
Contributor Author

@anyt @vsoroka I created a micro bundle (https://github.com/pedrofurtado/orocrm-firstname-api-bundle) that has this funcionality out of box.

@anyt
Copy link
Contributor

anyt commented Apr 24, 2018

Look like a good example of simple api customization.

I guess the issue can be closed.

@pedrofurtado
Copy link
Contributor Author

@anyt Thanks for feedback! The issue can be closed.

@sadortun
Copy link
Contributor

sadortun commented Nov 2, 2018

@pedrofurtado can you share publicly your micro-bundle ? It would be useful to us :)

Thanks in advance !

@pedrofurtado
Copy link
Contributor Author

pedrofurtado commented Jun 24, 2019

@sadortun I uploaded the bundle to github: https://github.com/pedrofurtado/orocrm-firstname-api-bundle

It is also available for download in Composer 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants