Bad path element "password" after: /user

Hi,

I am trying to change user password via maapi and i am having an issue as the following.

The output of execution is below
user admin is exists:
2022-05-31T07:21:38.718365427Z TRACE MAAPI_EXISTS user{admin} → CONFD_OK
2022-05-31T07:21:38.718753035Z TRACE MAAPI_GET_ELEM /user{admin}/passwordDEBUG badly formatted or nonexistent path - Bad path element “password” after: /user

My code is below and im following confd user guide.

        maapi_init_cursor(msock, th, &mc, "/aaa/authentication/users");

        if (maapi_exists(msock, th, "user/{%s}", userName) !=CONFD_OK) {
            printf("user %s is not exists:\n", userName);
            fflush(stdout);
            return CONFD_ERR;
        }
        printf("user %s is  exists:\n", userName);
        fflush(stdout);
        // Check newPassword and confirmPassword are same
        if (strcmp(newPassword, confirmPassword) != 0) {
            printf("Password confirmation is wrong: %s\n", confd_lasterr());
            return CONFD_ERR;
        }

        // Check old password
        if (maapi_get_str_elem(msock, th, buf, BUFSIZ,
                               "/user{%s}/password", userName) == CONFD_OK) {
            if (strcmp(oldPassword, buf) != 0) {
                printf("Old Password is wrong");
                return CONFD_ERR;
            }
        }

Seems like there is a slash “/“ before “user” that should be removed. "/user{%s}/pas…”. Or you need to add the full path “/aaa/authentication/users”.

1 Like

Thanks, full path worked.