Comments (14)
Is anybody else having the same issue? Am I using
plone.restapi
wrong?
Yes, today the same happend here.
from plone.restapi.
@ale-rt
I can confirm, that the patch helps. Thanks.
from plone.restapi.
@ale-rt if you need help, let me know
from plone.restapi.
@ale-rt with your patch in zope the following test doesn't fail in my Project :
def test_querystringsearch_metadata_fields_get_request_as_anon(self):
from urllib.parse import quote
import json
self.api_session = RelativeSession(self.portal_url, test=self)
self.api_session.headers.update({"Accept": "application/json"})
self.api_session.headers.update({"Content-Type": "application/json"})
data = {
"query": [
{
"i": "portal_type",
"o": "plone.app.querystring.operation.selection.is",
"v": ["News Item"],
}
],
"metadata_fields": ["image_scales", "getIcon"],
}
response = self.api_session.get(
"/@querystring-search",
proxies=self._proxies,
params={"query": quote(json.dumps(data))},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic")
self.assertEqual(
response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching"
)
Note: The Project use the master branch of plone.restapi with a fix for the GET Request in Endpoint @querystring-search
, but it'S not related to these issue
Update: I will check, what happens when i removing the content-type header
from plone.restapi.
I am closing this one because I think the details are now clear: you shall not send a Content-Type header on a GET request :)
I opened a PR for pat-calendar: Patternslib/Patterns#1157
from plone.restapi.
@ale-rt The thing I don't understand about this is: why is Zope throwing an error about having both a querystring and a body when you didn't send a body?
from plone.restapi.
I did not get it as well and did not dig into the issue enough to grok it :)
I am temporarily using this branch to make the site work: zopefoundation/Zope#1117
from plone.restapi.
@ale-rt i will check the workaround tomorrow. I have upgraded today a Plone Site from 6.0.0.3 to 6.0.3 and see the error in a custom Rest-API endpoint call. It's a simple GET Request with a parameter.
from plone.restapi.
I will try to dig deeper and make the patch merged.
from plone.restapi.
I dug in to the issue and came up with a different patch that I think is more comprehensive.
The problem is that the current code does not actually check there is a body in the request.
from plone.restapi.
@1letter did you by chance has the issue while using pat-calendar?
It seems it is mistakenly adding the Content-Type
header here:
https://github.com/Patternslib/Patterns/blob/7e391d33ed84bf8461d7c0c04f80ec157c23e549/src/pat/calendar/calendar.js#L311-L318
I will probably transfer this issue there.
from plone.restapi.
@ale-rt no, it was a custom rest-api endpoint call. It's a simple GET Request with a parameter. but the structure is similar like you linked.
from plone.restapi.
As you noted, the reason why your test fails should be this line:
self.api_session.headers.update({"Content-Type": "application/json"})
You should not need it (see zopefoundation/Zope#1117 (review)).
from plone.restapi.
@ale-rt You were correct, the useless header with an empty body in the GET request was the problem.
from plone.restapi.
Related Issues (20)
- CI Badge HOT 2
- Github Actions are skipped HOT 3
- Undeprecate comma separated expansion parameters HOT 8
- Undeprecate token parameter from vocabularies endpoint HOT 9
- Code that seems to do nothing HOT 2
- Drop Python 3.7 support HOT 1
- jwt_auth PAS plugin is active without being installed HOT 9
- Global Site tabs should also be customizable with customize_entry HOT 5
- navigation_base_url is not also used here HOT 2
- json_body should not read entire request BODY HOT 5
- debug-exceptions = on in instance part in buildout causes requests that return BadRequest to be returned as html instead of json
- KeyError: 'portal' in tests with Python 3.12.1 HOT 10
- Translate validation error messages
- IBlocks SearchableText indexer bypasses plone.textindexer behavior HOT 2
- relatedItems field returns None in the serializer if the related item is deleted HOT 1
- Site Administrator cannot add user to group
- Add remote_url(getRemoteUrl) to link content-types in navigation HOT 4
- Include release notes in Plone 6 Documentation
- Authentication error messages from PAS Plugins aren't returned by the restapi HOT 1
- restapi double parameter is broking code. HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plone.restapi.