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

API - Add support for request content in JSON #359

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Josue-T
Copy link
Contributor

@Josue-T Josue-T commented Jul 12, 2024

Problem

Using yunhost admin API with as REST API has not issue.

By example when we use it with the requests lib passing the parameter is straightforward. And I didn't find a working solution to pass correctly an UTF-8 easily with requests.

Solution

Add a working support for REST request with JSON content type.

Note that for now the authentication is not supported by this way. But the issue currently is on the other request which could be difficult to write to make it working correctly.

How to test

By example we requests we can test this way:

import requests
s = requests.Session()
s.headers['X-Requested-With'] = 'Client'
s.post("https://domain.tld/yunohost/api/login", data={"credentials": "%s:%s" % ("user", "pwd")})
s.post("https://domain.tld/yunohost/api/users", json={"username": "yolotest", "fullname": "Fullname Withspécialchàr", "password": "pwd", "domain": "domain.tld"})

@Josue-T Josue-T requested a review from alexAubin July 12, 2024 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant