Edit project properties via API #19867
-
|
If I understand correctly the API endpoint POST /api/projects/ (for creating a project) doesn't allow to set "license" and "instructions" fields. I assume one needs to edit the project using PATCH /api/projects/(string: project)/ or PUT /api/projects/(string: project)/, which I'm not understanding how to use correctly. I'm getting 404 not found error. What should I pass to these two PATCH/PUT endpoints to successfully edit the project's fields? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Looks like the path wants the project slug, not a URL/id/name. In current Weblate docs/source the update endpoint is {"instructions":"...","license":"MIT"}I didn’t try a write against your instance, but if the copied detail URL still gives 404, I’d check whether that token can see/edit the project, since the API filters projects by access. |
Beta Was this translation helpful? Give feedback.
-
|
The documentation is incomplete; #19993 fixes that. We really need to migrate towards using OpenAPI here so that the documentation comes from the code and is not manually maintained; see #12584. |
Beta Was this translation helpful? Give feedback.
Looks like the path wants the project slug, not a URL/id/name.
In current Weblate docs/source the update endpoint is
PATCH /api/projects/(string:project)/, andProjectViewSetuseslookup_field = "slug". The hosted API also returns project URLs likehttps://hosted.weblate.org/api/projects/freeplane/, withinstructionsandlicenseon the project object. So I’d firstGET /api/projects/, copy theurlfor your project, then PATCH that exact URL with JSON, for example:{"instructions":"...","license":"MIT"}I didn’t try a write against your instance, but if the copied detail URL still gives 404, I’d check whether that token can see/edit the project, since the API filters projects by access.