UpdatinG User with JSON-PATCH method
-
Hey, we are using
User
API to update userPerferredLanguage
. Currently we have two languages and we want to change email template based on that user language.We want to have just one language at any given time so want to update the User
PerferredLanguage
using Json-patch method.User{ PerferredLanguage: [ "English"] }
when using
json-patch
https://fusionauth.io/docs/v1/tech/apis/#the-patch-http-method it seems like am not getting the path right. Looking at the example provide i cant why the request body from the example become[ { "op": "remove", "path": "/roleIds/1" } ]
How do we resolve to the
path
to become"path": "/roleIds/1"
?
or in my case, how would the body be ?Thanks
-
@dan It was abit confusing because looking at the original body of the
group
, there was no parameter/ field calledroleIds
but it was used in the request.To update the User we used this.
// To remove language let body = vec![Testing { op: "remove".to_string(), path: "/user/preferredLanguages/0".to_string() }];
-
Hiya,
I would have to play around with this for a while, but we've found this online tool to be useful when trying to figure out how to take one JSON document and transform it to another:
https://json-patch-builder-online.github.io/
Dan
-
@dan It was abit confusing because looking at the original body of the
group
, there was no parameter/ field calledroleIds
but it was used in the request.To update the User we used this.
// To remove language let body = vec![Testing { op: "remove".to_string(), path: "/user/preferredLanguages/0".to_string() }];
-
Sounds good, thanks for sharing.
I think groups were one of the first APIs and so have some quirks. Glad you figured it out.
-
@duke said in UpdatinG User with JSON-PATCH method:
@dan It was abit confusing because looking at the original body of the
group
, there was no parameter/ field calledroleIds
but it was used in the request.To update the User we used this.
// To remove language let body = vec![Testing { op: "remove".to_string(), path: "/user/preferredLanguages/0".to_string() }];
thanks my issue has been fixed.
-