I'm using the API. The responses are in XML format, even though I specified “format”: “json” in my input data (and I understand that json is the default format).
Here's some minimal python code to illustrate the problem
where we see that the response is ok, the Content-Type text/xml, and above all the content and text are xml.
Is there anything more we can do to get a json response? What else?
Version de Piwigo: 15.0.0
Version de PHP: 8.1
Version de MySQL:
URL Piwigo: http://galleries.grains-de-culture.fr/
I'm using the API. The responses are in XML format, even though I specified “format”: “json” in my input data (and I understand that json is the default format).
Here's some minimal python code to illustrate the problem
```
import requests
import configPiwigo as cp
url = "https://galleries.grains-de-culture.fr/ws.php"
auth_data = {
"format": "json", "method": "pwg.session.login",
"username": cp.configPiwigo["login"], "password": cp.configPiwigo["pass"],
}
session = requests.Session() # Crée une session persistante
response = session.post(url, data={**auth_data, **payload})
if response.ok and response.json().get("stat") == "ok":
print("Connexion réussie!")
```
and here's an extract from the response:
```
response = {Response} <Response [200]>
...
content = {bytes: 64} b'<?xml version="1.0" encoding="utf-8" ?>\n<rsp stat="ok">\n1\n</rsp>'
headers = {CaseInsensitiveDict: 11} {'Date': 'Sat, 09 Nov 2024 14:26:46 GMT', 'Content-Type': 'text/xml; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connecti...=/,
...
ok = {bool} True
...
status_code = {int} 200
text = {str} '<?xml version="1.0" encoding="utf-8" ?>\n<rsp stat="ok">\n1\n</rsp>'
url = {str} 'https://galleries.grains-de-culture.fr/ws.php'
```
where we see that the response is ok, the Content-Type text/xml, and above all the content and text are xml.
Is there anything more we can do to get a json response? What else?
<!-- github-sync-id:2646164841 -->
Can you try putting the format and method directly in the url like this ws.php?format=json&method=pwg.session.login ? In Piwigo to call the api we use this url formatting with only the format and method
Hello,
Can you try putting the format and method directly in the url like this `ws.php?format=json&method=pwg.session.login` ? In Piwigo to call the api we use this url formatting with only the `format` and `method`
<!-- github-comment-id:2470148924 -->
Thank'. The following is working and gives a response content in json format
import requests
import configPiwigo as cp
url = "https://galleries.grains-de-culture.fr/ws.php?format=json&method=pwg.session.login"
auth_data = {
"username": cp.configPiwigo["login"],
"password": cp.configPiwigo["pass"],
}
session = requests.Session() # Crée une session persistante
response = session.post(url, data=auth_data)
if response.ok and response.json().get("stat") == "ok":
print("Connexion réussie!")
Thank'. The following is working and gives a response content in json format
```
import requests
import configPiwigo as cp
url = "https://galleries.grains-de-culture.fr/ws.php?format=json&method=pwg.session.login"
auth_data = {
"username": cp.configPiwigo["login"],
"password": cp.configPiwigo["pass"],
}
session = requests.Session() # Crée une session persistante
response = session.post(url, data=auth_data)
if response.ok and response.json().get("stat") == "ok":
print("Connexion réussie!")
```
<!-- github-comment-id:2473890250 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Version de Piwigo: 15.0.0
Version de PHP: 8.1
Version de MySQL:
URL Piwigo: http://galleries.grains-de-culture.fr/
I'm using the API. The responses are in XML format, even though I specified “format”: “json” in my input data (and I understand that json is the default format).
Here's some minimal python code to illustrate the problem
and here's an extract from the response:
where we see that the response is ok, the Content-Type text/xml, and above all the content and text are xml.
Is there anything more we can do to get a json response? What else?
Hello,
Can you try putting the format and method directly in the url like this
ws.php?format=json&method=pwg.session.login? In Piwigo to call the api we use this url formatting with only theformatandmethodThank'. The following is working and gives a response content in json format