Admin API and PUT Method - 404?

Discussion in 'LiquidFiles General' started by Russell Meyer, Aug 15, 2019.

  1. Russell Meyer

    Russell Meyer New Member

    Joined:
    Aug 15, 2019
    Messages:
    5
    Likes Received:
    0
    Working on the API and I am able to get data, delete users, but when I attempt to update data via the PUT method it comes back with a 404 error...the json body looks good

    {
    "user": {
    "group": "dummygroup"
    }
    }

    but I am doing this with invoke-webrequest with powershell (which I am able to do with other JSON sites and also snag data above)

    $pair = "$($apikey):$($pass)"
    $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
    $base64 = [System.Convert]::ToBase64String($bytes)
    $basicAuthValue = "Basic $base64"
    $headers = @{'Authorization'=$basicAuthValue}

    $Website = "https://serverFQDN/admin/users/$userID" (which is legit info from the array, works for grabbing data)
    $UpdateGroup = [ordered]@{
    "user"=[ordered]@{
    "group"="dummygroup";
    }
    }
    $UpdateGroup = $UpdateGroup | ConvertTo-Json
    Invoke-WebRequest -Uri $TempWebsite -Headers $headers -Body $UpdateGroup -ContentType 'application/json' -Method put

    thoughts????
     
  2. David

    David Administrator
    Staff Member

    Joined:
    Dec 1, 2015
    Messages:
    802
    Likes Received:
    31
    Interesting, expect the group which should be updated, can you please try to add there some another attribute like the email address in to the request together with the group. The email just place there don't have to be changed.

    {"user":
    {
    "email": "user@domain.com",
    "group": "external-users"
    }

    }
     
    Russell Meyer likes this.
  3. Russell Meyer

    Russell Meyer New Member

    Joined:
    Aug 15, 2019
    Messages:
    5
    Likes Received:
    0
    that did it! that plus some formatting fun
     
  4. Paul Hirose

    Paul Hirose New Member

    Joined:
    Jan 10, 2020
    Messages:
    17
    Likes Received:
    0
    Thanks for this!
    I was also trying to change a user's group from localusers to another-group. For the world of me, it wouldn't let me do so, if the only attribute I was changing was the group. But I added another attribute (email) and set it to what it's already set to, and it works fine. I can change other attributes (eg: strong_auth_username) by itself, but for some reason, the group attribute seems to only be changeable if some other attribute is being changed.

    To me that seems like a bug (or at least missing in the docs) that some attributes are change-able by themselves while others are not.

    Glad I found this thread, thanks again,
    PH
     

Share This Page