-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
React Content Query WebPart - With Metadata Field #537
Comments
@marcelaopimenta sorry for the delay I just saw this issue. What do you mean when you say that the error only occurs when there's a "metadata" field, you mean a "Managed Metada" field as in a "Taxonomy" field? There must be something else with your list because the WebPart does support Taxonomy fields. It looks weird because as you pointed out, the only thing the WebPart does is a request to the specified URL (GET request not a POST) : /es/_api/web/lists/GetByTitle('Páginas')/Fields?$select=InternalName,Title,TypeAsString&$orderby=Title And that request should work no matter what kind of field you have in your list...What happens if you put the URL directly in the browser, does it work or you get the same error? Also, can you try with the latest version available on this repository? Because I see that the version you have uses the "GetByTitle" in the request, which is problematic because if you change your list title the WebPart will be linked to the old list title and it won't find it anymore. The WebPart has been updated to use the following now : let endpoint = Text.format("{0}/_api/web/lists(guid'{1}')/Fields?$select={2}&$orderby={3}", webUrl, listId, selectProps, order); This version uses the GUID of the list instead of the title, it's also less error prone with list that have special characters like yours. Please try the latest version and let me know if you still have the problem. |
Yes, is a Taxonomy field. I have one version older because some things customized. But, one thing is certain, the problem is not from SPFX or the WebPart, the problem is from SharePoint 2016 OnPremises. |
In Sharepoint 2016 On Premises dont work /_api/web/lists(guid'{1}')/Fields if you have a Taxonomy Field and use the Accept application/json;odata.metadata=minimal |
Yeah that's what I was scared of, because it is a simple REST request there is nothing fancy about it. Out of curiosity, could you use SharePoint Manager to extract the XML definition of the field and paste it here? I wonder if it's not a problem with the specific Taxonomy field that you added to the list, maybe in its name format or something like that. Is it a field that you deployed or it's a regular field created by the UI? |
In my project is an deployed field. But I got to create a new publishing site without data, went into the page library and added a new metadata field in a new TermSet, also created via interface. I also created sites in English and Spanish... Same faults. |
Interesting, what kind of "display name" did you specify when creating the field from the UI? Because when creating fields via the UI, SharePoint builds the internal name of the column using the specified display name, replacing spaces by encodings like x0020x and stuff like that. Did you try creating the column with a regular name without any space or special character at all? Otherwise it does look like a bug in SharePoint 2016, I have no SP2016 tenant to test on, but if you find a successfull way to execute a GET request with Postman to the problematic endpoint that works for both SP2016 and SPOnline, let me know, I will add the workaround in the project 👍 |
Hi Simon! The field calls Teste very simple name... If i post with: odata-version: 3.0 Works fine! What changes is the return structure of json, does not use the json light format, because it is verbose now. if you can create this workaround I will be grateful. Thanks! |
Can you make it work with a GET? Because there is no need to do a POST for getting information. Also, Im am not sure what is the difference between the actual code and the POST you just did, these should be the default settings used by SPFx odata-version: 3.0 |
I messed up, it's a GET and not a POST. Sharepoint Framework have two configurations in sp-http ODATA V3 ODATA V4 Today, your component using V4... but even if we use V3, it does not work, because only works if using application/json;odata=verbose;charset=utf-8 |
Oh I see, you can try specifying your own headers to the spHttpClient, since I don't have access to an SP2016 farm right now, let me know if you are able to specify the headers and make it work. If you do find a workaround with custom headers, I could test it for SPO and integrate it in the solution. Thanks! |
Hi Simon! Thanks for help! Its Works now!!!!! :-D In listservice.ts on method getListFields I have added the following code in getlistfields method. I check if Environment is Onpremises and added custom headers.
Change the spHttpClient.Get call for use options
In methods getFilterFields, getViewFieldsChecklistItems, i changed this point:
In Method getOrderByOptions i changed this point:
Thank you!!!! |
Good job, I will make sure to implement this is the official version. Meanwhile, I strongly suggest you to append all your changes to the latest version because at least two problems have been fixed since then :
Thanks again! |
Category
Hi...
I have one Environment with Sharepoint 2016 On-premises with latest CU.
In my site, i have one library with metadata fields... and if use React Content Query, occur this error...
This error An error occured while loading fields : Bad Request is beacause request a API /es/_api/web/lists/GetByTitle('Páginas')/Fields?$select=InternalName,Title,TypeAsString&$orderby=Title fails.
If anyone can help me.. :-D
Thanks !!!
The text was updated successfully, but these errors were encountered: