-
-
Notifications
You must be signed in to change notification settings - Fork 721
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
Update a Segment via API call #7987
Comments
Thanks @theomeuh we'll look into it, we have somewhat related work we're planning to take on soon, and I included this as part of that backlog, we'll keep you posted on this ticket. |
Hi @theomeuh, Thank you for bringing up this issue. We’ve reviewed your concerns and I’d like to provide some clarification and updates. You’re correct in pointing out that the behavior of the endpoint can be confusing, especially regarding how it handles PUT requests. While the API documentation indicates that unspecified fields will remain untouched (which would align more with PATCH behavior), the endpoint currently requires #8085 doesn’t really fix the issue, but at least it includes the request body schema, which is the same as the POST endpoint. In the meantime, for your specific use case of updating only the constraints, a potential workaround would be to include the We acknowledge that the current behavior is far from great, and we'll take this into consideration when we discuss the future of our API and respective OpenAPI spec. |
https://linear.app/unleash/issue/2-2592/updateimprove-a-segment-via-api-call Related to #7987 This does not make the endpoint necessarily better - It's still a PUT that acts as a PUT in some ways (expects specific required fields to be present, resets the project to `null` if it's not included in the body) and a PATCH in others (ignores most fields if they're not included in the body). We need to have a more in-depth discussion about developing long-term strategies for our API and respective OpenAPI spec. However this at least includes the proper schema for the request body, which is slightly better than before.
Discussed in https://github.com/orgs/Unleash/discussions/7980
Originally posted by theomeuh August 26, 2024
I'm trying to migrate some data we have in Unleash and I need to automatically update Segment via API. I'm referring to this endpoint: https://docs.getunleash.io/reference/api/unleash/update-segment
Context
It says: "Any fields not specified will be left untouched", but if I try to PUT an empty body, I got a 400 Bad Request
{"id":"1dd37e9f-2b75-458b-b7ca-1424e0561479","name":"BadDataError","message":"Request validation failed: your request body or params contain invalid data. Refer to the
detailslist for more information.","details":[{"message":"\"name\" is required."}]}
Then let's add a "dummy name".. I got the same message but this time, it is the field "constraints" which is apparently missing.
My question: is the doc up-to-date ? It really looks like a PUT (like the endpoint verb says) and not a PATCH (like the description says), do you confirm ?
PS: what I really want is to update "constraints" but unfortunately, I have the "name is required" error when I try to just push a payload with only "constraints"
Current behavior
A PUT requests on
api/admin/segments/:id
with in body a json containing only the keyconstraints
returns a 400, saying the fieldname
is requiredExpected behavior
A PUT requests on
api/admin/segments/:id
with in body a json containing only the keyconstraints
must return a 200 (and update theconstraints
field)The text was updated successfully, but these errors were encountered: